Upgraded gradlew and added custom state.

This commit is contained in:
Mathieu 2020-04-28 20:19:04 +02:00
parent f7a52a982c
commit bf0b510cf0
17 changed files with 93 additions and 82 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

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

Binary file not shown.

View File

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Fri Jul 19 19:58:39 CEST 2019
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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip

74
gradlew vendored
View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env sh
############################################################################## ##############################################################################
## ##
@ -6,12 +6,30 @@
## ##
############################################################################## ##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Attempt to set APP_HOME
DEFAULT_JVM_OPTS="" # Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` 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. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@ -30,6 +48,7 @@ die ( ) {
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false
case "`uname`" in case "`uname`" in
CYGWIN* ) CYGWIN* )
cygwin=true cygwin=true
@ -40,31 +59,11 @@ case "`uname`" in
MINGW* ) MINGW* )
msys=true msys=true
;; ;;
NONSTOP* )
nonstop=true
;;
esac 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"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
@ -90,7 +89,7 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n` MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@ -114,6 +113,7 @@ fi
if $cygwin ; then if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@ -154,11 +154,19 @@ if $cygwin ; then
esac esac
fi fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules # Escape application args
function splitJvmOpts() { save () {
JVM_OPTS=("$@") for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
} }
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS APP_ARGS=$(save "$@")
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" # 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" "$@"

14
gradlew.bat vendored
View File

@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal 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 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% 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 @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail goto fail
:init :init
@rem Get command-line arguments, handling Windowz variants @rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args :win9xME_args
@rem Slurp the command line arguments. @rem Slurp the command line arguments.
@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%* set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute :execute
@rem Setup the command line @rem Setup the command line

View File

@ -9,7 +9,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
public class Utils { public class Utils {
@ -27,7 +27,7 @@ public class Utils {
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
uc.getInputStream(); uc.getInputStream();
InputStream is = uc.getInputStream(); InputStream is = uc.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
int ch; int ch;
while ((ch = in.read()) != -1) { while ((ch = in.read()) != -1) {
@ -47,7 +47,7 @@ public class Utils {
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));
} catch (Exception e) { } catch (Exception ignored) {
} }
return variable; return variable;
@ -63,26 +63,20 @@ public class Utils {
JSONObject inInventory = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inInventory"); JSONObject inInventory = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inInventory");
switch (id) { switch (id) {
case 0:
Main.proxy.rpcupdate(replaceArgsString(Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message")), null, false);
break;
case 1: case 1:
Main.proxy.rpcupdate(replaceArgsString(onJoinServer.getString("message")), null, false); Main.proxy.rpcupdate(replaceArgsString(onJoinServer.getString("message")), getState(onJoinServer), false);
break; break;
case 2: case 2:
Main.proxy.rpcupdate(replaceArgsString(onQuitServer.getString("message")), null, false); Main.proxy.rpcupdate(replaceArgsString(onQuitServer.getString("message")), getState(onQuitServer), false);
break; break;
case 3: case 3:
Main.proxy.rpcupdate(replaceArgsString(inPauseMenu.getString("message")), null, false); Main.proxy.rpcupdate(replaceArgsString(inPauseMenu.getString("message")), getState(inPauseMenu), false);
break; break;
case 4: case 4:
Main.proxy.rpcupdate(replaceArgsString(inMainMenu.getString("message")), null, false); Main.proxy.rpcupdate(replaceArgsString(inMainMenu.getString("message")), getState(inMainMenu), false);
break; break;
case 5: case 5:
Main.proxy.rpcupdate(replaceArgsString(inInventory.getString("message")), null, false); Main.proxy.rpcupdate(replaceArgsString(inInventory.getString("message")), getState(inInventory), false);
break;
case 6:
Main.proxy.rpcupdate(replaceArgsString(Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getString("message")), null, false);
break; break;
default: default:
break; break;
@ -90,8 +84,16 @@ public class Utils {
}); });
t.start(); t.start();
}
private String getState(JSONObject jsonObject) {
String state = replaceArgsString(Main.config_object.getString("state"));
if (jsonObject.getBoolean("showState")) {
return state;
}
return null;
} }
} }

View File

@ -32,7 +32,7 @@ public class AdvancedStatusEvent {
JSONObject onQuitServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer"); JSONObject onQuitServer = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer");
if (onQuitServer.getBoolean("enable")) { if (onQuitServer.getBoolean("enable")) {
Utils.instance.updateStatus(1); Utils.instance.updateStatus(2);
} }
} }
@ -63,7 +63,7 @@ public class AdvancedStatusEvent {
if (event.getGui() == null) { if (event.getGui() == null) {
if (Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getBoolean("enable")) { if (Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getBoolean("enable")) {
Utils.instance.updateStatus(6); Utils.instance.updateStatus(1);
} }
} }
} }

View File

@ -38,11 +38,11 @@ public class EventPresence {
presence.startTimestamp = System.currentTimeMillis() / 1000L; presence.startTimestamp = System.currentTimeMillis() / 1000L;
oldTime = presence.startTimestamp; oldTime = presence.startTimestamp;
} else { } else {
System.out.println(presence.startTimestamp);
System.out.println(oldTime);
presence.startTimestamp = oldTime; presence.startTimestamp = oldTime;
} }
} else if (action != null) { }
if (action != null) {
presence.state = action; presence.state = action;
} }
DiscordRPC.discordUpdatePresence(presence); DiscordRPC.discordUpdatePresence(presence);

View File

@ -5,6 +5,7 @@
"_comment4": "%server-max-slot% - Nombre de slots du serveur", "_comment4": "%server-max-slot% - Nombre de slots du serveur",
"server-ip": "mc.hypixel.net", "server-ip": "mc.hypixel.net",
"server-port": "25565", "server-port": "25565",
"state": "%server-connected-player%/%server-max-slot% joueurs connectés",
"application-settings": { "application-settings": {
"applicationID": "601875975533232158", "applicationID": "601875975533232158",
"large-image-name": "discord_logo", "large-image-name": "discord_logo",
@ -13,22 +14,27 @@
"advanced-status-custom": { "advanced-status-custom": {
"onJoinServer": { "onJoinServer": {
"enable": true, "enable": true,
"showState": true,
"message": "En jeu." "message": "En jeu."
}, },
"onQuitServer": { "onQuitServer": {
"enable": true, "enable": true,
"showState": false,
"message": "Dans le menu principal." "message": "Dans le menu principal."
}, },
"inPauseMenu": { "inPauseMenu": {
"enable": true, "enable": true,
"showState": true,
"message": "Dans le menu pause." "message": "Dans le menu pause."
}, },
"inMainMenu": { "inMainMenu": {
"enable": true, "enable": true,
"showState": false,
"message": "Dans le menu principal." "message": "Dans le menu principal."
}, },
"inInventory": { "inInventory": {
"enable": false, "enable": false,
"showState": true,
"message": "Dans l'inventaire." "message": "Dans l'inventaire."
} }
} }