From c778304401e9244cb987aaafa39f930561567c87 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 30 Aug 2019 15:45:54 +0200 Subject: [PATCH] Add run option in Server property file --- .../fr/pandacube/java/util/ServerPropertyFile.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/fr/pandacube/java/util/ServerPropertyFile.java b/src/main/java/fr/pandacube/java/util/ServerPropertyFile.java index 65b0646..c13b6e4 100644 --- a/src/main/java/fr/pandacube/java/util/ServerPropertyFile.java +++ b/src/main/java/fr/pandacube/java/util/ServerPropertyFile.java @@ -8,6 +8,7 @@ import java.io.FileWriter; import java.io.IOException; import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; public class ServerPropertyFile { @@ -18,6 +19,7 @@ public class ServerPropertyFile { private String javaArgs = ""; private String MinecraftArgs = ""; private String jarFile = ""; + private boolean run = true; public ServerPropertyFile(File f) { if (f == null) throw new IllegalArgumentException("f ne doit pas ĂȘtre null"); @@ -40,8 +42,12 @@ public class ServerPropertyFile { javaArgs = dataFile.javaArgs; MinecraftArgs = dataFile.MinecraftArgs; jarFile = dataFile.jarFile; + run = dataFile.run; return true; + } catch(JsonSyntaxException e) { + Log.severe("Error in config file " + file + ": backed up and creating a new one from previous or default values.", e); + return save(); } catch (IOException e) { Log.severe(e); return false; @@ -81,6 +87,10 @@ public class ServerPropertyFile { public String getJarFile() { return jarFile; } + + public boolean isRun() { + return run; + } public void setName(String n) { if (n == null || !n.matches("^[a-zA-Z]$")) throw new IllegalArgumentException(); @@ -106,5 +116,9 @@ public class ServerPropertyFile { if (j == null) throw new IllegalArgumentException(); jarFile = j; } + + public void setRun(boolean r) { + run = r; + } }