From 128212d00988b57bcb05b954cd4e6677a38b7756 Mon Sep 17 00:00:00 2001 From: BloodWorkXGaming Date: Tue, 5 Jun 2018 18:29:20 +0200 Subject: [PATCH] Added preJava Arg, allowed Xms arg in list --- build.gradle | 2 +- server-setup-config.yaml | 4 ++++ .../serverstarter/ForgeManager.java | 16 ++++++++++------ .../serverstarter/config/LaunchSettings.java | 2 ++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index d1004f2..dc81f3f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'atm.bloodworkxgaming' -version = '1.2.1' +version = '1.2.2' sourceCompatibility = 1.8 diff --git a/server-setup-config.yaml b/server-setup-config.yaml index 8e4b5b8..1d09037 100644 --- a/server-setup-config.yaml +++ b/server-setup-config.yaml @@ -90,6 +90,10 @@ launch: # syntax is either [number]h or [number]min or [number]s crashTimer: 60min + # Arguments that need to go before the 'java' argument, something like linux niceness + # This is only a string, not a list. + preJavaArgs: ~ + # Java args that are supposed to be used when the server launches # keep in mind java args often need ' - ' in front of it to work, use clarifying parentheses to make sure it uses it correctly javaArgs: diff --git a/src/main/java/atm/bloodworkxgaming/serverstarter/ForgeManager.java b/src/main/java/atm/bloodworkxgaming/serverstarter/ForgeManager.java index 92f94d2..9095721 100644 --- a/src/main/java/atm/bloodworkxgaming/serverstarter/ForgeManager.java +++ b/src/main/java/atm/bloodworkxgaming/serverstarter/ForgeManager.java @@ -150,16 +150,20 @@ private void startServer() { List arguments = new ArrayList<>(); + arguments.add(configFile.launch.preJavaArgs); arguments.add("java"); arguments.addAll(configFile.launch.javaArgs); arguments.add("-Xmx" + configFile.launch.maxRam); - try { - int xmx = Integer.parseInt(configFile.launch.maxRam.substring(0, configFile.launch.maxRam.length() - 1)); - int xms = Math.max(1, xmx / 2); - arguments.add("-Xms" + xms + configFile.launch.maxRam.substring(configFile.launch.maxRam.length() - 1)); - } catch (NumberFormatException e) { - LOGGER.error("Problem while calculating XMS", e); + if (configFile.launch.javaArgs.stream().noneMatch(s -> s.trim().startsWith("-Xms"))){ + try { + int xmx = Integer.parseInt(configFile.launch.maxRam.substring(0, configFile.launch.maxRam.length() - 1)); + int xms = Math.max(1, xmx / 2); + arguments.add("-Xms" + xms + configFile.launch.maxRam.substring(configFile.launch.maxRam.length() - 1)); + + } catch (NumberFormatException e) { + LOGGER.error("Problem while calculating XMS", e); + } } diff --git a/src/main/java/atm/bloodworkxgaming/serverstarter/config/LaunchSettings.java b/src/main/java/atm/bloodworkxgaming/serverstarter/config/LaunchSettings.java index c04dd06..3f2253c 100644 --- a/src/main/java/atm/bloodworkxgaming/serverstarter/config/LaunchSettings.java +++ b/src/main/java/atm/bloodworkxgaming/serverstarter/config/LaunchSettings.java @@ -17,9 +17,11 @@ public class LaunchSettings { public int crashLimit; public String crashTimer; public List javaArgs; + public String preJavaArgs; public LaunchSettings normalize(){ if (javaArgs == null) javaArgs = Collections.emptyList(); + if (preJavaArgs == null) preJavaArgs = ""; return this; }