From 383b09a53e466ac7fd84a171cabe29c63e5db58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Mon, 16 Jan 2023 02:07:27 +0100 Subject: [PATCH] Register shutdown hook without relying on Sun proprietary method --- src/main/java/wtf/beatrice/hidekobot/HidekoBot.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java index b5ce394..5118cba 100644 --- a/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java +++ b/src/main/java/wtf/beatrice/hidekobot/HidekoBot.java @@ -6,7 +6,6 @@ import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.requests.GatewayIntent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import sun.misc.Signal; import wtf.beatrice.hidekobot.commands.completer.ProfileImageCommandCompleter; import wtf.beatrice.hidekobot.commands.message.HelloCommand; import wtf.beatrice.hidekobot.commands.slash.*; @@ -225,7 +224,7 @@ public class HidekoBot } // register shutdown interrupt signal listener for proper shutdown. - Signal.handle(new Signal("INT"), signal -> shutdown()); + Runtime.getRuntime().addShutdownHook(new Thread(HidekoBot::shutdown)); // set startup time. Cache.setStartupTime(LocalDateTime.now()); @@ -248,7 +247,5 @@ public class HidekoBot { LOGGER.warn("WARNING! Shutting down!"); if(jda != null) jda.shutdown(); - System.exit(0); } - }