make shutdowns safer

This commit is contained in:
Pyrbu 2024-01-08 09:37:31 +01:00
parent 2a1f44b1bb
commit 683e48a974

@ -202,7 +202,12 @@ public class ZNpcsPlus {
public void onDisable() {
NpcApiProvider.unregister();
for (Runnable runnable : shutdownTasks) runnable.run();
for (Runnable runnable : shutdownTasks) try {
runnable.run();
} catch (Throwable throwable) {
bootstrap.getLogger().severe("One of the registered shutdown tasks threw an exception:");
throwable.printStackTrace();
}
shutdownTasks.clear();
PacketEvents.getAPI().terminate();
}