Tries a new fix to remove the pesky FileNotFoundException caused by the server version container
Some checks failed
KnarCraft/Minecraft-Server-Launcher/pipeline/head There was a failure building this commit

This commit is contained in:
2020-08-17 11:26:45 +02:00
parent 8e626d8097
commit c721aef2a6
3 changed files with 41 additions and 1 deletions

View File

@ -92,6 +92,11 @@ public class ServerVersionContainer implements java.io.Serializable {
PrintWriter file;
try {
if (!saveFile.exists()) {
if (!saveFile.getParentFile().exists()) {
if (!saveFile.getParentFile().mkdirs()) {
throw new FileNotFoundException("Unable to create folder for version file");
}
}
if (!saveFile.createNewFile()) {
throw new FileNotFoundException("Unable to create version file");
}

View File

@ -1,5 +1,6 @@
package net.knarcraft.minecraftserverlauncher.utility;
import net.knarcraft.minecraftserverlauncher.Main;
import net.knarcraft.minecraftserverlauncher.userinterface.ServerLauncherGUI;
import java.io.*;
@ -20,6 +21,33 @@ import java.util.Scanner;
*/
public final class CommonFunctions {
private static String filesDirectory = Main.getApplicationWorkDirectory() + File.separator + "files";
/**
* Creates all folders necessary for tests and normal operation
*
* @throws FileNotFoundException <p>If unable to create a folder</p>
*/
public static void createAllFolders() throws FileNotFoundException {
createFolder(new File(filesDirectory));
createFolder(new File(filesDirectory + File.separator + "Jars"));
createFolder(new File(filesDirectory + File.separator + "testjars"));
}
/**
* Creates a given folder
*
* @param folder <p>The folder to create</p>
* @throws FileNotFoundException <p>If unable to create the folder</p>
*/
private static void createFolder(File folder) throws FileNotFoundException {
if (!folder.exists()) {
if (!folder.mkdirs()) {
throw new FileNotFoundException("Cannot create necessary directory.");
}
}
}
/**
* Gets a resource as an InputStream
*