Catch plugin enable disable errors

This commit is contained in:
LOOHP 2023-01-10 15:03:58 +00:00
parent 69bd4a8f6f
commit 9f2c426a50
2 changed files with 13 additions and 5 deletions

View File

@ -24,7 +24,7 @@
<groupId>com.loohp</groupId> <groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId> <artifactId>Limbo</artifactId>
<name>Limbo</name> <name>Limbo</name>
<version>0.7.1-ALPHA</version> <version>0.7.2-ALPHA</version>
<description>Standalone Limbo Minecraft Server.</description> <description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url> <url>https://github.com/LOOHP/Limbo</url>

View File

@ -338,8 +338,12 @@ public final class Limbo {
} }
for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) { for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) {
console.sendMessage("Enabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion()); try {
plugin.onEnable(); 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()); server = new ServerConnection(properties.getServerIp(), properties.getServerPort());
@ -553,8 +557,12 @@ public final class Limbo {
console.sendMessage("Stopping Server..."); console.sendMessage("Stopping Server...");
for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) { for (LimboPlugin plugin : Limbo.getInstance().getPluginManager().getPlugins()) {
console.sendMessage("Disabling plugin " + plugin.getName() + " " + plugin.getInfo().getVersion()); try {
plugin.onDisable(); 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); tick.waitAndKillThreads(5000);