From 9f2c426a50d0ae368e03b35f1793d4b9f2e8ccd4 Mon Sep 17 00:00:00 2001 From: LOOHP Date: Tue, 10 Jan 2023 15:03:58 +0000 Subject: [PATCH] Catch plugin enable disable errors --- pom.xml | 2 +- src/main/java/com/loohp/limbo/Limbo.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 7205fc8..a5bf495 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ com.loohp Limbo Limbo - 0.7.1-ALPHA + 0.7.2-ALPHA Standalone Limbo Minecraft Server. https://github.com/LOOHP/Limbo diff --git a/src/main/java/com/loohp/limbo/Limbo.java b/src/main/java/com/loohp/limbo/Limbo.java index af422ef..1f4192f 100644 --- a/src/main/java/com/loohp/limbo/Limbo.java +++ b/src/main/java/com/loohp/limbo/Limbo.java @@ -338,8 +338,12 @@ public final class Limbo { } for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) { - console.sendMessage("Enabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion()); - plugin.onEnable(); + try { + console.sendMessage("Enabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion()); + plugin.onEnable(); + } catch (Throwable e) { + new RuntimeException("Error while enabling " + plugin.getName() + " " + plugin.getInfo().getVersion(), e).printStackTrace(); + } } server = new ServerConnection(properties.getServerIp(), properties.getServerPort()); @@ -553,8 +557,12 @@ public final class Limbo { console.sendMessage("Stopping Server..."); for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) { - console.sendMessage("Disabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion()); - plugin.onDisable(); + try { + console.sendMessage("Disabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion()); + plugin.onDisable(); + } catch (Throwable e) { + new RuntimeException("Error while disabling " + plugin.getName() + " " + plugin.getInfo().getVersion(), e).printStackTrace(); + } } tick.waitAndKillThreads(5000);