From 57a3300ce6dc9bf6395f66844b2ab9442878fbc3 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 25 Jun 2024 12:21:10 +0200 Subject: [PATCH] make exit more friendly --- .../src/main/java/de/com/baseband/launcher/Loader.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Loader/src/main/java/de/com/baseband/launcher/Loader.java b/Loader/src/main/java/de/com/baseband/launcher/Loader.java index 82da8eb..24bbf51 100644 --- a/Loader/src/main/java/de/com/baseband/launcher/Loader.java +++ b/Loader/src/main/java/de/com/baseband/launcher/Loader.java @@ -191,7 +191,7 @@ public class Loader implements Util { } }) .spacer() - .option("Exit Minecraft", x -> exit()) + .option("Exit Minecraft", x -> exit(0)) .show(); options.setIfAbsent("ip", "baseband.com.de"); options.setIfAbsent("disabled-modules", new TCNArray()); @@ -222,7 +222,7 @@ public class Loader implements Util { out.close(); LOGGER.info("BaseBand has downloaded a significant update. Minecraft will exit."); JOptionPane.showMessageDialog(null, "BaseBand has downloaded a significant update. Please restart Minecraft."); - exit(); + exit(0); } else if(status == Response.OK) { LOGGER.info(status.name); try { @@ -349,12 +349,16 @@ public class Loader implements Util { public static void exit() { + exit(1); + } + + public static void exit(int exitCode) { try { //Cleanly exit Class shutdownClass = Class.forName("java.lang.Shutdown"); Method exitMethod = shutdownClass.getDeclaredMethod("exit", int.class); exitMethod.setAccessible(true); - exitMethod.invoke(null, 1); + exitMethod.invoke(null, exitCode); } catch (Exception ignored) { } }