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
*/
public void saveState() {
File saveFile = new File(versionFile);
PrintWriter file;
try {
if (!saveFile.exists()) {
if (!saveFile.createNewFile()) {
throw new FileNotFoundException("Unable to create version file");
}
}
file = new PrintWriter(versionFile);
file.println(this.toString());
file.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
}
}