mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 13:54:37 +01:00
Fix plugin on enable event not being called
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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++;
|
||||||
|
|||||||
Reference in New Issue
Block a user