From 94d5b609ff3b8bbf11500af71afa6754f1e2be10 Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Feb 2017 18:52:11 +0100 Subject: [PATCH] Made loader only register commands if the module was loaded successfully --- .../coremods/moduleLoader/ModuleLoader.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java index 54d5273..77e83ec 100644 --- a/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java +++ b/src/com/redstoner/coremods/moduleLoader/ModuleLoader.java @@ -21,7 +21,7 @@ import com.redstoner.modules.Module; /** The module loader, mother of all modules. Responsible for loading and taking care of all modules. * * @author Pepich */ -@Version(major = 1, minor = 2, revision = 0, compatible = -1) +@Version(major = 1, minor = 3, revision = 0, compatible = -1) public final class ModuleLoader implements CoreModule { private static ModuleLoader instance; @@ -48,7 +48,6 @@ public final class ModuleLoader implements CoreModule { Module module = clazz.newInstance(); modules.add(module); - CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); } catch (InstantiationException | IllegalAccessException e) { @@ -61,20 +60,21 @@ public final class ModuleLoader implements CoreModule public static final void enableModules() { Debugger.notifyMethod(); - for (Module m : modules) + for (Module module : modules) { - if (m.enabled()) + if (module.enabled()) continue; - if (m.enable()) + if (module.enable()) { - if (m.getClass().isAnnotationPresent(AutoRegisterListener.class) && (m instanceof Listener)) + CommandManager.registerCommand(module.getCommandString(), module, Main.plugin); + if (module.getClass().isAnnotationPresent(AutoRegisterListener.class) && (module instanceof Listener)) { - Bukkit.getPluginManager().registerEvents((Listener) m, Main.plugin); + Bukkit.getPluginManager().registerEvents((Listener) module, Main.plugin); } - Utils.log("Loaded module " + m.getClass().getName()); + Utils.log("Loaded module " + module.getClass().getName()); } else - Utils.error("Failed to load module " + m.getClass().getName()); + Utils.error("Failed to load module " + module.getClass().getName()); } }