Fix plugin on enable event not being called

This commit is contained in:
Melledy
2024-02-21 01:55:48 -08:00
parent f82fd023a8
commit dd9646cfc8
2 changed files with 3 additions and 1 deletions

View File

@@ -65,7 +65,6 @@ public abstract class Plugin {
* *
* @return True if the config is valid, false otherwise. * @return True if the config is valid, false otherwise.
*/ */
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean validate() { public boolean validate() {
return name != null && description != null && mainClass != null && api != null; return name != null && description != null && mainClass != null && api != null;
} }

View File

@@ -38,6 +38,7 @@ public final class PluginManager {
* Loads all plugins from the plugins directory. * Loads all plugins from the plugins directory.
* This can only be called once. * This can only be called once.
*/ */
@SuppressWarnings("resource")
public void loadPlugins() throws IOException { public void loadPlugins() throws IOException {
if (this.pluginsLoaded) if (this.pluginsLoaded)
throw new IllegalStateException("Plugins have already been loaded."); throw new IllegalStateException("Plugins have already been loaded.");
@@ -143,6 +144,7 @@ public final class PluginManager {
)); ));
} else try { } else try {
pluginInstance.onLoad(); pluginInstance.onLoad();
this.plugins.put(pluginInstance.getName(), pluginInstance);
} catch (Throwable exception) { } catch (Throwable exception) {
this.getLogger().warn("Failed to load plugin {}.", pluginFile.getName()); this.getLogger().warn("Failed to load plugin {}.", pluginFile.getName());
} }
@@ -179,6 +181,7 @@ public final class PluginManager {
// Load the plugin. // Load the plugin.
pluginData.instance().onLoad(); pluginData.instance().onLoad();
this.plugins.put(pluginData.instance().getName(), pluginData.instance());
} catch (Throwable exception) { } catch (Throwable exception) {
this.getLogger().warn("Failed to load plugin {}.", exception.getMessage()); this.getLogger().warn("Failed to load plugin {}.", exception.getMessage());
depth++; depth++;