Made loader only register commands if the module was loaded successfully
This commit is contained in:
parent
0fe41a40a9
commit
94d5b609ff
@ -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.
|
/** The module loader, mother of all modules. Responsible for loading and taking care of all modules.
|
||||||
*
|
*
|
||||||
* @author Pepich */
|
* @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
|
public final class ModuleLoader implements CoreModule
|
||||||
{
|
{
|
||||||
private static ModuleLoader instance;
|
private static ModuleLoader instance;
|
||||||
@ -48,7 +48,6 @@ public final class ModuleLoader implements CoreModule
|
|||||||
{
|
{
|
||||||
Module module = clazz.newInstance();
|
Module module = clazz.newInstance();
|
||||||
modules.add(module);
|
modules.add(module);
|
||||||
CommandManager.registerCommand(module.getCommandString(), module, Main.plugin);
|
|
||||||
}
|
}
|
||||||
catch (InstantiationException | IllegalAccessException e)
|
catch (InstantiationException | IllegalAccessException e)
|
||||||
{
|
{
|
||||||
@ -61,20 +60,21 @@ public final class ModuleLoader implements CoreModule
|
|||||||
public static final void enableModules()
|
public static final void enableModules()
|
||||||
{
|
{
|
||||||
Debugger.notifyMethod();
|
Debugger.notifyMethod();
|
||||||
for (Module m : modules)
|
for (Module module : modules)
|
||||||
{
|
{
|
||||||
if (m.enabled())
|
if (module.enabled())
|
||||||
continue;
|
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
|
else
|
||||||
Utils.error("Failed to load module " + m.getClass().getName());
|
Utils.error("Failed to load module " + module.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user