Refresh the state
This commit is contained in:
parent
bf0b510cf0
commit
2b489d3bf5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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.
|
//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
|
group = "ch.m4th1eu.richpresence" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "richpresence"
|
archivesBaseName = "richpresence"
|
||||||
|
|
||||||
|
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@ -14,6 +14,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final Utils instance = new Utils();
|
public static final Utils instance = new Utils();
|
||||||
|
public static int status = 0;
|
||||||
|
|
||||||
public static String readTextFromURL(String url) throws IOException {
|
public static String readTextFromURL(String url) throws IOException {
|
||||||
URL urlObject;
|
URL urlObject;
|
||||||
@ -45,8 +46,11 @@ public class Utils {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
variable = variable.replaceAll("%player-name%", Minecraft.getMinecraft().getSession().getUsername());
|
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));
|
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) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +60,8 @@ public class Utils {
|
|||||||
public void updateStatus(int id) {
|
public void updateStatus(int id) {
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
|
|
||||||
|
status = id;
|
||||||
|
|
||||||
JSONObject onQuitServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
|
JSONObject onQuitServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
|
||||||
JSONObject onJoinServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer");
|
JSONObject onJoinServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer");
|
||||||
JSONObject inPauseMenu = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu");
|
JSONObject inPauseMenu = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu");
|
||||||
@ -88,6 +94,7 @@ public class Utils {
|
|||||||
|
|
||||||
private String getState(JSONObject jsonObject) {
|
private String getState(JSONObject jsonObject) {
|
||||||
String state = replaceArgsString(Main.config_object.getString("state"));
|
String state = replaceArgsString(Main.config_object.getString("state"));
|
||||||
|
System.out.println(state);
|
||||||
|
|
||||||
if (jsonObject.getBoolean("showState")) {
|
if (jsonObject.getBoolean("showState")) {
|
||||||
return state;
|
return state;
|
||||||
|
@ -9,6 +9,7 @@ import net.minecraft.client.gui.inventory.GuiInventory;
|
|||||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,6 +18,12 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
|||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class AdvancedStatusEvent {
|
public class AdvancedStatusEvent {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onTickEvent(TickEvent.WorldTickEvent event) {
|
||||||
|
if (event.world.getTotalWorldTime() % 1024 == 0) {
|
||||||
|
Utils.instance.updateStatus(Utils.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
|
public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent event) {
|
||||||
|
Reference in New Issue
Block a user