From 953268330118cc3ed1aa4c4c5e84feea5accb25e Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 23 Aug 2021 16:43:35 +0200 Subject: [PATCH] Fixes a NumberFormatException when running custom versions without a version number --- .../minecraftserverlauncher/server/Server.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/knarcraft/minecraftserverlauncher/server/Server.java b/src/main/java/net/knarcraft/minecraftserverlauncher/server/Server.java index 0486361..3be1016 100644 --- a/src/main/java/net/knarcraft/minecraftserverlauncher/server/Server.java +++ b/src/main/java/net/knarcraft/minecraftserverlauncher/server/Server.java @@ -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) { - return controller.getJavaCommand(); - } else { - return controller.getOldJavaCommand(); + } else if (serverVersion.contains(".") && serverVersion.split("\\.").length >= 2) { + try { + if (Integer.parseInt(serverVersion.split("\\.")[1]) >= 17) { + return controller.getJavaCommand(); + } + } catch (NumberFormatException ignored) {} } + return controller.getOldJavaCommand(); } /**