Add run option in Server property file

This commit is contained in:
Marc Baloup 2019-08-30 15:45:54 +02:00
parent 92a1d21b3b
commit c778304401

View File

@ -8,6 +8,7 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
public class ServerPropertyFile { public class ServerPropertyFile {
@ -18,6 +19,7 @@ public class ServerPropertyFile {
private String javaArgs = ""; private String javaArgs = "";
private String MinecraftArgs = ""; private String MinecraftArgs = "";
private String jarFile = ""; private String jarFile = "";
private boolean run = true;
public ServerPropertyFile(File f) { public ServerPropertyFile(File f) {
if (f == null) throw new IllegalArgumentException("f ne doit pas être null"); if (f == null) throw new IllegalArgumentException("f ne doit pas être null");
@ -40,8 +42,12 @@ public class ServerPropertyFile {
javaArgs = dataFile.javaArgs; javaArgs = dataFile.javaArgs;
MinecraftArgs = dataFile.MinecraftArgs; MinecraftArgs = dataFile.MinecraftArgs;
jarFile = dataFile.jarFile; jarFile = dataFile.jarFile;
run = dataFile.run;
return true; 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) { } catch (IOException e) {
Log.severe(e); Log.severe(e);
return false; return false;
@ -81,6 +87,10 @@ public class ServerPropertyFile {
public String getJarFile() { public String getJarFile() {
return jarFile; return jarFile;
} }
public boolean isRun() {
return run;
}
public void setName(String n) { public void setName(String n) {
if (n == null || !n.matches("^[a-zA-Z]$")) throw new IllegalArgumentException(); if (n == null || !n.matches("^[a-zA-Z]$")) throw new IllegalArgumentException();
@ -106,5 +116,9 @@ public class ServerPropertyFile {
if (j == null) throw new IllegalArgumentException(); if (j == null) throw new IllegalArgumentException();
jarFile = j; jarFile = j;
} }
public void setRun(boolean r) {
run = r;
}
} }