diff --git a/.gradle/4.8.1/fileHashes/fileHashes.bin b/.gradle/4.8.1/fileHashes/fileHashes.bin index 41d6ebf..d745aae 100644 Binary files a/.gradle/4.8.1/fileHashes/fileHashes.bin and b/.gradle/4.8.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/4.8.1/fileHashes/fileHashes.lock b/.gradle/4.8.1/fileHashes/fileHashes.lock index b348db9..69434c2 100644 Binary files a/.gradle/4.8.1/fileHashes/fileHashes.lock and b/.gradle/4.8.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/4.8.1/taskHistory/taskHistory.bin b/.gradle/4.8.1/taskHistory/taskHistory.bin index 0dfbde6..7f3481d 100644 Binary files a/.gradle/4.8.1/taskHistory/taskHistory.bin and b/.gradle/4.8.1/taskHistory/taskHistory.bin differ diff --git a/.gradle/4.8.1/taskHistory/taskHistory.lock b/.gradle/4.8.1/taskHistory/taskHistory.lock index 2ff2923..e1dec1e 100644 Binary files a/.gradle/4.8.1/taskHistory/taskHistory.lock and b/.gradle/4.8.1/taskHistory/taskHistory.lock differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index c9e16a7..8f63ca0 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin index 8e6f517..0c2a0e1 100644 Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/build.gradle b/build.gradle index 68b5422..b5fd6dc 100644 --- a/build.gradle +++ b/build.gradle @@ -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.5" +version = "1.6" group = "ch.m4th1eu.richpresence" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "richpresence" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2d80b69..0a39e29 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue Apr 28 20:22:31 CEST 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/ch/m4th1eu/richpresence/Utils.java b/src/main/java/ch/m4th1eu/richpresence/Utils.java index 3891835..044f734 100644 --- a/src/main/java/ch/m4th1eu/richpresence/Utils.java +++ b/src/main/java/ch/m4th1eu/richpresence/Utils.java @@ -14,6 +14,7 @@ import java.nio.charset.StandardCharsets; public class Utils { public static final Utils instance = new Utils(); + public static int status = 0; public static String readTextFromURL(String url) throws IOException { URL urlObject; @@ -45,8 +46,11 @@ public class Utils { 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-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) { } @@ -56,6 +60,8 @@ public class Utils { public 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"); @@ -88,6 +94,7 @@ public class Utils { private String getState(JSONObject jsonObject) { String state = replaceArgsString(Main.config_object.getString("state")); + System.out.println(state); if (jsonObject.getBoolean("showState")) { return state; diff --git a/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java b/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java index 134dd58..6468738 100644 --- a/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java +++ b/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java @@ -9,6 +9,7 @@ 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; /** @@ -17,6 +18,12 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent; @Mod.EventBusSubscriber public class AdvancedStatusEvent { + @SubscribeEvent + public void onTickEvent(TickEvent.WorldTickEvent event) { + if (event.world.getTotalWorldTime() % 1024 == 0) { + Utils.instance.updateStatus(Utils.status); + } + } @SubscribeEvent public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {