Fixes a FileNotFoundException caused by the version file not existing
Some checks failed
KnarCraft/Minecraft-Server-Launcher/pipeline/head There was a failure building this commit

This commit is contained in:
Kristian Knarvik 2020-08-15 20:55:29 +02:00
parent 0bf355c4de
commit 8e626d8097

View File

@ -88,12 +88,18 @@ public class ServerVersionContainer implements java.io.Serializable {
* Tries to save the state of this server version container * Tries to save the state of this server version container
*/ */
public void saveState() { public void saveState() {
File saveFile = new File(versionFile);
PrintWriter file; PrintWriter file;
try { try {
if (!saveFile.exists()) {
if (!saveFile.createNewFile()) {
throw new FileNotFoundException("Unable to create version file");
}
}
file = new PrintWriter(versionFile); file = new PrintWriter(versionFile);
file.println(this.toString()); file.println(this.toString());
file.close(); file.close();
} catch (FileNotFoundException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }