Compare commits

..

No commits in common. "master" and "X.X" have entirely different histories.
master ... X.X

26 changed files with 231 additions and 206 deletions

View File

@ -1,2 +0,0 @@
#Tue Apr 28 20:17:19 CEST 2020
gradle.version=4.8.1

View File

@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
version = "1.6"
version = "1.2"
group = "ch.m4th1eu.richpresence" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "richpresence"
@ -24,7 +24,7 @@ compileJava {
minecraft {
version = "1.12.2-14.23.5.2768"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
@ -39,7 +39,7 @@ dependencies {
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"
// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
@ -66,11 +66,11 @@ processResources {
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'

View File

@ -0,0 +1,16 @@
[
{
"modid": "richpresence",
"name": "Discord Rich Presence Mod",
"description": "Un mod pour ajouter Rich Presence",
"version": "1.0",
"mcversion": "1.12.2",
"url": "https://mathieubroillet.ch/",
"updateUrl": "",
"authorList": ["M4TH1EU_"],
"credits": "RPC Lib author(s)",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]

View File

@ -0,0 +1,7 @@
{
"pack": {
"description": "examplemod resources",
"pack_format": 3,
"_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)."
}
}

Binary file not shown.

View File

@ -1,6 +1,6 @@
#Tue Apr 28 20:22:31 CEST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
#Fri Jul 19 19:58:39 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip

110
gradlew vendored
View File

@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
##############################################################################
##
@ -6,6 +6,47 @@
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@ -20,49 +61,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -89,7 +90,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@ -113,7 +114,6 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@ -154,19 +154,11 @@ if $cygwin ; then
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
APP_ARGS=$(save "$@")
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

14
gradlew.bat vendored
View File

@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@ -46,9 +46,10 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@ -59,6 +60,11 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line

View File

@ -4,19 +4,19 @@ import ch.m4th1eu.json.JSONObject;
import ch.m4th1eu.richpresence.events.AdvancedStatusEvent;
import ch.m4th1eu.richpresence.events.EventPresence;
import ch.m4th1eu.richpresence.proxy.CommonProxy;
import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.Logger;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
/**
* @author M4TH1EU_#0001
@ -25,7 +25,7 @@ import java.io.InputStreamReader;
public class Main {
public static final String MODID = "richpresence";
public static final String NAME = "Discord Rich Presence";
public static final String VERSION = "1.5";
public static final String VERSION = "1.2";
@Mod.Instance(Main.MODID)
public static Main instance;
@ -37,8 +37,6 @@ public class Main {
* Variables pour la config
*/
public static String applicationId, largeimage, largeimagetext;
public static String config_file_text = "";
public static JSONObject config_object;
public static Logger logger;
@ -51,22 +49,55 @@ public class Main {
//Configuration
event.getModConfigurationDirectory().mkdir();
File config_file = new File(event.getModConfigurationDirectory(), "\\" + Main.MODID + ".json");
if (!config_file.exists() || config_file.length() < 10) {
try {
event.getModLog().warn("Impossible de charger la configuration du mod : " + Main.MODID);
event.getModLog().warn("Création du fichier de configuration");
InputStream in = getClass().getResourceAsStream("/config/richpresence.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
try {
config_file_text = IOUtils.toString(reader);
config_object = new JSONObject(config_file_text);
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
if (config_file_text != null || config_file_text.length() < 10) {
event.getModLog().warn("Impossible de charger la configuration du mod : " + Main.MODID);
PrintWriter writer = new PrintWriter(config_file, "UTF-8");
writer.println("{\n" +
" \"_comment\": \"Variables disponibles :\",\n" +
" \"_comment2\": \"%player-name% - Nom du joueur.\",\n" +
" \"_comment3\": \"%server-connected-player% - Nombre de joueur connecté au serveur.\",\n" +
" \"_comment4\": \"%server-max-slot% - Nombre de slots du serveur\",\n" +
" \"server-ip\": \"mc.hypixel.net\",\n" +
" \"server-port\": \"25565\",\n" +
" \"application-settings\": {\n" +
" \"applicationID\": \"601875975533232158\",\n" +
" \"large-image-name\": \"discord_logo\",\n" +
" \"large-image-text\": \"En train de tester ce mod !\"\n" +
" },\n" +
" \"advanced-status-custom\": {\n" +
" \"onJoinServer\": {\n" +
" \"enable\": true,\n" +
" \"message\": \"En jeu.\"\n" +
" },\n" +
" \"onQuitServer\": {\n" +
" \"enable\": true,\n" +
" \"message\": \"Dans le menu principal.\"\n" +
" },\n" +
" \"inPauseMenu\": {\n" +
" \"enable\": true,\n" +
" \"message\": \"Dans le menu pause.\"\n" +
" },\n" +
" \"inMainMenu\": {\n" +
" \"enable\": true,\n" +
" \"message\": \"Dans le menu principal.\"\n" +
" },\n" +
" \"inInventory\": {\n" +
" \"enable\": false,\n" +
" \"message\": \"Dans l'inventaire.\"\n" +
" }\n" +
" }\n" +
"}");
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
@ -75,18 +106,20 @@ public class Main {
MinecraftForge.EVENT_BUS.register(instance);
MinecraftForge.EVENT_BUS.register(new AdvancedStatusEvent());
JSONObject config = new JSONObject(Utils.readFileToString(new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json")));
applicationId = config_object.getJSONObject("application-settings").getString("applicationID");
largeimage = config_object.getJSONObject("application-settings").getString("large-image-name");
largeimagetext = Utils.instance.replaceArgsString(config_object.getJSONObject("application-settings").getString("large-image-text"));
applicationId = config.getJSONObject("application-settings").getString("applicationID");
largeimage = config.getJSONObject("application-settings").getString("large-image-name");
largeimagetext = Utils.replaceArgsString(config.getJSONObject("application-settings").getString("large-image-text"));
proxy.init();
rpcClient = new EventPresence();
proxy.rpcinit();
if (config_object.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getBoolean("enable")) {
proxy.rpcupdate(config_object.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message"), null, true);
if (config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getBoolean("enable")) {
proxy.rpcupdate(config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message"), null, true);
} else {
proxy.rpcupdate("", null, false);
}

View File

@ -3,19 +3,40 @@ package ch.m4th1eu.richpresence;
import ch.m4th1eu.json.JSONObject;
import net.minecraft.client.Minecraft;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.nio.charset.Charset;
public class Utils {
public static final Utils instance = new Utils();
public static int status = 0;
/**
* @author Nathanaël#4314
*/
public static String readFileToString(File file) {
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder stringBuilder = new StringBuilder();
String line;
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
reader.close();
return stringBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
return "ERROR";
}
}
/**
* @author Nathanael
*/
public static String readTextFromURL(String url) throws IOException {
URL urlObject;
URLConnection uc;
@ -28,7 +49,7 @@ public class Utils {
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
uc.getInputStream();
InputStream is = uc.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
BufferedReader in = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
int ch;
while ((ch = in.read()) != -1) {
@ -40,49 +61,53 @@ public class Utils {
/**
* @author M4TH1EU_
*/
public String replaceArgsString(String variable) {
String serverip = Main.config_object.getString("server-ip");
String serverport = Main.config_object.getString("server-port");
public static String replaceArgsString(String variable) {
File config_file = new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json");
JSONObject config = new JSONObject(Utils.readFileToString(config_file));
String serverip = config.getString("server-ip");
String serverport = config.getString("server-port");
try {
variable = variable.replaceAll("%player-name%", Minecraft.getMinecraft().getSession().getUsername());
variable = variable.replaceAll("%server-connected-player%",
readTextFromURL("https://api.serveurs-minecraft.com/api.php?Joueurs_En_Ligne_Ping&ip=" + serverip + "&port=" + serverport));
variable = variable.replaceAll("%server-max-slot%", readTextFromURL("https://api.serveurs-minecraft.com/api.php?Joueurs_Maximum_Ping&ip=" + serverip + "&port=" + serverport));
System.out.println(readTextFromURL("https://api.serveurs-minecraft.com/api.php?Joueurs_En_Ligne_Ping&ip=" + serverip + "&port=" + serverport));
} catch (Exception ignored) {
variable = variable.replaceAll("%server-connected-player%", readTextFromURL("https://minecraft-api.com/api/ping/playeronline.php?ip=" + serverip + "&port=" + serverport));
variable = variable.replaceAll("%server-max-slot%", readTextFromURL("https://minecraft-api.com/api/ping/maxplayer.php?ip=" + serverip + "&port=" + serverport));
} catch (Exception e) {
}
return variable;
}
public void updateStatus(int id) {
public static void updateStatus(int id) {
Thread t = new Thread(() -> {
status = id;
JSONObject onQuitServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
JSONObject onJoinServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer");
JSONObject inPauseMenu = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu");
JSONObject inMainMenu = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu");
JSONObject inInventory = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inInventory");
JSONObject config = new JSONObject(Utils.readFileToString(new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json")));
JSONObject onQuitServer = config.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
JSONObject onJoinServer = config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer");
JSONObject inPauseMenu = config.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu");
JSONObject inMainMenu = config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu");
JSONObject inInventory = config.getJSONObject("advanced-status-custom").getJSONObject("inInventory");
switch (id) {
case 0:
Main.proxy.rpcupdate(Utils.replaceArgsString(config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message")), null, false);
break;
case 1:
Main.proxy.rpcupdate(replaceArgsString(onJoinServer.getString("message")), getState(onJoinServer), false);
Main.proxy.rpcupdate(Utils.replaceArgsString(onJoinServer.getString("message")), null, false);
break;
case 2:
Main.proxy.rpcupdate(replaceArgsString(onQuitServer.getString("message")), getState(onQuitServer), false);
Main.proxy.rpcupdate(Utils.replaceArgsString(onQuitServer.getString("message")), null, false);
break;
case 3:
Main.proxy.rpcupdate(replaceArgsString(inPauseMenu.getString("message")), getState(inPauseMenu), false);
Main.proxy.rpcupdate(Utils.replaceArgsString(inPauseMenu.getString("message")), null, false);
break;
case 4:
Main.proxy.rpcupdate(replaceArgsString(inMainMenu.getString("message")), getState(inMainMenu), false);
Main.proxy.rpcupdate(Utils.replaceArgsString(inMainMenu.getString("message")), null, false);
break;
case 5:
Main.proxy.rpcupdate(replaceArgsString(inInventory.getString("message")), getState(inInventory), false);
Main.proxy.rpcupdate(Utils.replaceArgsString(inInventory.getString("message")), null, false);
break;
case 6:
Main.proxy.rpcupdate(Utils.replaceArgsString(config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getString("message")), null, false);
break;
default:
break;
@ -90,17 +115,8 @@ public class Utils {
});
t.start();
}
private String getState(JSONObject jsonObject) {
String state = replaceArgsString(Main.config_object.getString("state"));
System.out.println(state);
if (jsonObject.getBoolean("showState")) {
return state;
}
return null;
}
}

View File

@ -3,74 +3,72 @@ package ch.m4th1eu.richpresence.events;
import ch.m4th1eu.json.JSONObject;
import ch.m4th1eu.richpresence.Main;
import ch.m4th1eu.richpresence.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiIngameMenu;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
import java.io.File;
/**
* @author M4TH1EU_#0001
*/
@Mod.EventBusSubscriber
public class AdvancedStatusEvent {
@SubscribeEvent
public void onTickEvent(TickEvent.WorldTickEvent event) {
if (event.world.getTotalWorldTime() % 1024 == 0) {
Utils.instance.updateStatus(Utils.status);
}
}
File config_file = new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json");
JSONObject config = new JSONObject(Utils.readFileToString(config_file));
@SubscribeEvent
public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
JSONObject onJoinServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer");
JSONObject onJoinServer = config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer");
if (onJoinServer.getBoolean("enable")) {
Utils.instance.updateStatus(1);
Utils.updateStatus(1);
}
}
@SubscribeEvent
public void onQuitServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
JSONObject onQuitServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
JSONObject onQuitServer = config.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
if (onQuitServer.getBoolean("enable")) {
Utils.instance.updateStatus(2);
Utils.updateStatus(1);
}
}
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
JSONObject inPauseMenu = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu");
JSONObject inMainMenu = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu");
JSONObject inInventory = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inInventory");
JSONObject inPauseMenu = config.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu");
JSONObject inMainMenu = config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu");
JSONObject inInventory = config.getJSONObject("advanced-status-custom").getJSONObject("inInventory");
if (inPauseMenu.getBoolean("enable")) {
if (event.getGui() instanceof GuiIngameMenu) {
Utils.instance.updateStatus(3);
Utils.updateStatus(3);
}
}
if (inMainMenu.getBoolean("enable")) {
if (event.getGui() instanceof GuiMainMenu) {
Utils.instance.updateStatus(4);
Utils.updateStatus(4);
}
}
if (inInventory.getBoolean("enable")) {
if (event.getGui() instanceof GuiInventory) {
Utils.instance.updateStatus(5);
Utils.updateStatus(5);
}
}
if (event.getGui() == null) {
if (Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getBoolean("enable")) {
Utils.instance.updateStatus(1);
if (config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getBoolean("enable")) {
Utils.updateStatus(6);
}
}
}

View File

@ -15,7 +15,7 @@ public class EventPresence {
public synchronized static void init() {
DiscordEventHandlers handlers = new DiscordEventHandlers();
DiscordRPC.discordInitialize(Main.applicationId, handlers, true);
DiscordRPC.discordInitialize(Main.applicationId, handlers, true, null);
if (EventPresence.callbackRunner == null) {
(EventPresence.callbackRunner = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) {
@ -27,7 +27,7 @@ public class EventPresence {
Main.logger.info("EventPresence has been started.");
}
public static void updatePresence(String details, String action, Boolean changeTime) {
public synchronized static void updatePresence(String details, String action, Boolean changeTime) {
DiscordRichPresence presence = new DiscordRichPresence();
presence.largeImageKey = Main.largeimage;
presence.largeImageText = Main.largeimagetext;
@ -38,11 +38,11 @@ public class EventPresence {
presence.startTimestamp = System.currentTimeMillis() / 1000L;
oldTime = presence.startTimestamp;
} else {
System.out.println(presence.startTimestamp);
System.out.println(oldTime);
presence.startTimestamp = oldTime;
}
}
if (action != null) {
} else if (action != null) {
presence.state = action;
}
DiscordRPC.discordUpdatePresence(presence);

View File

@ -1,41 +0,0 @@
{
"_comment": "Variables disponibles :",
"_comment2": "%player-name% - Nom du joueur.",
"_comment3": "%server-connected-player% - Nombre de joueur connecté au serveur.",
"_comment4": "%server-max-slot% - Nombre de slots du serveur",
"server-ip": "mc.hypixel.net",
"server-port": "25565",
"state": "%server-connected-player%/%server-max-slot% joueurs connectés",
"application-settings": {
"applicationID": "601875975533232158",
"large-image-name": "discord_logo",
"large-image-text": "En train de tester ce mod !"
},
"advanced-status-custom": {
"onJoinServer": {
"enable": true,
"showState": true,
"message": "En jeu."
},
"onQuitServer": {
"enable": true,
"showState": false,
"message": "Dans le menu principal."
},
"inPauseMenu": {
"enable": true,
"showState": true,
"message": "Dans le menu pause."
},
"inMainMenu": {
"enable": true,
"showState": false,
"message": "Dans le menu principal."
},
"inInventory": {
"enable": false,
"showState": true,
"message": "Dans l'inventaire."
}
}
}