make exit more friendly
All checks were successful
/ Build BaseBand Loader (push) Successful in 1m43s

This commit is contained in:
Daniella / Tove 2024-06-25 12:21:10 +02:00
parent 1b66efcde0
commit 57a3300ce6
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -191,7 +191,7 @@ public class Loader implements Util {
} }
}) })
.spacer() .spacer()
.option("Exit Minecraft", x -> exit()) .option("Exit Minecraft", x -> exit(0))
.show(); .show();
options.setIfAbsent("ip", "baseband.com.de"); options.setIfAbsent("ip", "baseband.com.de");
options.setIfAbsent("disabled-modules", new TCNArray()); options.setIfAbsent("disabled-modules", new TCNArray());
@ -222,7 +222,7 @@ public class Loader implements Util {
out.close(); out.close();
LOGGER.info("BaseBand has downloaded a significant update. Minecraft will exit."); LOGGER.info("BaseBand has downloaded a significant update. Minecraft will exit.");
JOptionPane.showMessageDialog(null, "BaseBand has downloaded a significant update. Please restart Minecraft."); JOptionPane.showMessageDialog(null, "BaseBand has downloaded a significant update. Please restart Minecraft.");
exit(); exit(0);
} else if(status == Response.OK) { } else if(status == Response.OK) {
LOGGER.info(status.name); LOGGER.info(status.name);
try { try {
@ -349,12 +349,16 @@ public class Loader implements Util {
public static void exit() { public static void exit() {
exit(1);
}
public static void exit(int exitCode) {
try { try {
//Cleanly exit //Cleanly exit
Class<?> shutdownClass = Class.forName("java.lang.Shutdown"); Class<?> shutdownClass = Class.forName("java.lang.Shutdown");
Method exitMethod = shutdownClass.getDeclaredMethod("exit", int.class); Method exitMethod = shutdownClass.getDeclaredMethod("exit", int.class);
exitMethod.setAccessible(true); exitMethod.setAccessible(true);
exitMethod.invoke(null, 1); exitMethod.invoke(null, exitCode);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} }