[Add] MiraiMain 增加正常关闭过程;

This commit is contained in:
LamGC 2020-04-19 13:03:10 +08:00
parent 084be3970a
commit 36460e4c34

View File

@ -24,6 +24,7 @@ public class MiraiMain implements Closeable {
private final static Properties botProperties = new Properties(); private final static Properties botProperties = new Properties();
public void init() { public void init() {
Runtime.getRuntime().addShutdownHook(new Thread(this::close));
try { try {
Class.forName(BotEventHandler.class.getName()); Class.forName(BotEventHandler.class.getName());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
@ -47,7 +48,9 @@ public class MiraiMain implements Closeable {
} }
public void close() { public void close() {
log.warn("正在关闭机器人...");
bot.close(null); bot.close(null);
log.warn("机器人已关闭.");
} }
} }