Updated the ServerConfiguration.java

This commit is contained in:
Mathias Wagner 2024-02-14 00:50:48 +01:00
parent ff01c76130
commit b9e0ead151
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -14,7 +14,7 @@ public class ServerConfiguration {
private final static Logger LOG = new Logger(ServerConfiguration.class);
@Expose(serialize = false, deserialize = false)
private File file;
public File file;
@Expose
private String name;
@ -59,13 +59,25 @@ public class ServerConfiguration {
}
}
public ServerConfiguration(String name, String type, String version, String description, int memory, boolean autoStart) {
this.name = name;
this.type = type;
this.version = version;
this.description = description;
this.memory = memory;
this.autoStart = autoStart;
}
public ServerConfiguration() {
}
/**
* Saves the server configuration to the file
*/
public void save() {
if (file == null) return;
Gson gson = new Gson();
String json = gson.toJson(this);
String json = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(this);
try {
FileUtils.writeStringToFile(file, json, "UTF-8");