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