Fixes a NumberFormatException when running custom versions without a version number
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2021-08-23 16:43:35 +02:00
parent 365d08f2e2
commit 9532683301

View File

@ -345,6 +345,7 @@ public class Server {
return false;
}
if (ServerHandler.stoppingServers()) {
gui.logMessage("Stopping servers. Cannot start yet.");
return false;
}
//Starts the server if possible
@ -367,14 +368,17 @@ public class Server {
*/
private String getJavaCommand() {
ServerLauncherController controller = ServerLauncherController.getInstance();
if (serverVersion.toLowerCase().contains("latest")) {
return controller.getJavaCommand();
} else if (serverVersion.contains(".") && serverVersion.split("\\.").length >= 2 &&
Integer.parseInt(serverVersion.split("\\.")[1]) >= 17) {
} else if (serverVersion.contains(".") && serverVersion.split("\\.").length >= 2) {
try {
if (Integer.parseInt(serverVersion.split("\\.")[1]) >= 17) {
return controller.getJavaCommand();
} else {
return controller.getOldJavaCommand();
}
} catch (NumberFormatException ignored) {}
}
return controller.getOldJavaCommand();
}
/**