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
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
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 bash
#!/usr/bin/env sh
##############################################################################
##
@ -6,47 +6,6 @@
##
##############################################################################
# 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"
@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
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
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -90,7 +89,7 @@ location of your Java installation."
fi
# 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`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@ -114,6 +113,7 @@ 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,11 +154,19 @@ if $cygwin ; then
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")
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
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,10 +46,9 @@ echo location of your Java installation.
goto fail
: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 "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@ -60,11 +59,6 @@ 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

@ -9,7 +9,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
public class Utils {
@ -27,7 +27,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, Charset.forName("UTF-8")));
BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
int ch;
while ((ch = in.read()) != -1) {
@ -47,7 +47,7 @@ public class Utils {
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));
} catch (Exception e) {
} catch (Exception ignored) {
}
return variable;
@ -63,26 +63,20 @@ public class Utils {
JSONObject inInventory = Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inInventory");
switch (id) {
case 0:
Main.proxy.rpcupdate(replaceArgsString(Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message")), null, false);
break;
case 1:
Main.proxy.rpcupdate(replaceArgsString(onJoinServer.getString("message")), null, false);
Main.proxy.rpcupdate(replaceArgsString(onJoinServer.getString("message")), getState(onJoinServer), false);
break;
case 2:
Main.proxy.rpcupdate(replaceArgsString(onQuitServer.getString("message")), null, false);
Main.proxy.rpcupdate(replaceArgsString(onQuitServer.getString("message")), getState(onQuitServer), false);
break;
case 3:
Main.proxy.rpcupdate(replaceArgsString(inPauseMenu.getString("message")), null, false);
Main.proxy.rpcupdate(replaceArgsString(inPauseMenu.getString("message")), getState(inPauseMenu), false);
break;
case 4:
Main.proxy.rpcupdate(replaceArgsString(inMainMenu.getString("message")), null, false);
Main.proxy.rpcupdate(replaceArgsString(inMainMenu.getString("message")), getState(inMainMenu), false);
break;
case 5:
Main.proxy.rpcupdate(replaceArgsString(inInventory.getString("message")), null, false);
break;
case 6:
Main.proxy.rpcupdate(replaceArgsString(Main.config_object.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getString("message")), null, false);
Main.proxy.rpcupdate(replaceArgsString(inInventory.getString("message")), getState(inInventory), false);
break;
default:
break;
@ -90,8 +84,16 @@ public class Utils {
});
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");
if (onQuitServer.getBoolean("enable")) {
Utils.instance.updateStatus(1);
Utils.instance.updateStatus(2);
}
}
@ -63,7 +63,7 @@ public class AdvancedStatusEvent {
if (event.getGui() == null) {
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;
oldTime = presence.startTimestamp;
} else {
System.out.println(presence.startTimestamp);
System.out.println(oldTime);
presence.startTimestamp = oldTime;
}
} else if (action != null) {
}
if (action != null) {
presence.state = action;
}
DiscordRPC.discordUpdatePresence(presence);

View File

@ -5,6 +5,7 @@
"_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",
@ -13,22 +14,27 @@
"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."
}
}