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 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;
@ -82,6 +88,10 @@ public class ServerPropertyFile {
return jarFile;
}
public boolean isRun() {
return run;
}
public void setName(String n) {
if (n == null || !n.matches("^[a-zA-Z]$")) throw new IllegalArgumentException();
name = n;
@ -107,4 +117,8 @@ public class ServerPropertyFile {
jarFile = j;
}
public void setRun(boolean r) {
run = r;
}
}