From dd9646cfc8df527dcc42922539645e10bd554686 Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Wed, 21 Feb 2024 01:55:48 -0800 Subject: [PATCH] Fix plugin on enable event not being called --- src/main/java/emu/lunarcore/plugin/Plugin.java | 1 - src/main/java/emu/lunarcore/plugin/PluginManager.java | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/lunarcore/plugin/Plugin.java b/src/main/java/emu/lunarcore/plugin/Plugin.java index fa0d296..d8c307e 100644 --- a/src/main/java/emu/lunarcore/plugin/Plugin.java +++ b/src/main/java/emu/lunarcore/plugin/Plugin.java @@ -65,7 +65,6 @@ public abstract class Plugin { * * @return True if the config is valid, false otherwise. */ - @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean validate() { return name != null && description != null && mainClass != null && api != null; } diff --git a/src/main/java/emu/lunarcore/plugin/PluginManager.java b/src/main/java/emu/lunarcore/plugin/PluginManager.java index 90bc02b..13c1c3c 100644 --- a/src/main/java/emu/lunarcore/plugin/PluginManager.java +++ b/src/main/java/emu/lunarcore/plugin/PluginManager.java @@ -38,6 +38,7 @@ public final class PluginManager { * Loads all plugins from the plugins directory. * This can only be called once. */ + @SuppressWarnings("resource") public void loadPlugins() throws IOException { if (this.pluginsLoaded) throw new IllegalStateException("Plugins have already been loaded."); @@ -143,6 +144,7 @@ public final class PluginManager { )); } else try { pluginInstance.onLoad(); + this.plugins.put(pluginInstance.getName(), pluginInstance); } catch (Throwable exception) { this.getLogger().warn("Failed to load plugin {}.", pluginFile.getName()); } @@ -179,6 +181,7 @@ public final class PluginManager { // Load the plugin. pluginData.instance().onLoad(); + this.plugins.put(pluginData.instance().getName(), pluginData.instance()); } catch (Throwable exception) { this.getLogger().warn("Failed to load plugin {}.", exception.getMessage()); depth++;