summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinenash <minenash@protonmail.com>2019-01-13 00:42:29 -0500
committerMinenash <minenash@protonmail.com>2019-01-13 00:42:29 -0500
commitae5494f203e2141197a1b6e5472612032c409fb1 (patch)
tree7cc773a1e92d0245e603529ee77df39dde149f93
parentbf0b5994f0db5e3550583de49daf6b489d63c790 (diff)
Fixed module loading, with caveats*.
* Unfortunately it still won't remove the commands from the TabComplete * ChatAPI's error message for now unregistered commands, have been changed to lessen the confusion.
-rw-r--r--src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java
index 109fc27..0a4cdf9 100644
--- a/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java
+++ b/src/main/java/com/redstoner/coremods/moduleLoader/ModuleLoader.java
@@ -5,7 +5,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@@ -40,7 +39,7 @@ import net.nemez.chatapi.click.Message;
/** The module loader, mother of all modules. Responsible for loading and taking care of all modules.
*
* @author Pepich */
-@Version(major = 5, minor = 0, revision = 0, compatible = 5)
+@Version(major = 5, minor = 1, revision = 0, compatible = 5)
public final class ModuleLoader implements CoreModule
{
private static ModuleLoader instance;
@@ -370,8 +369,7 @@ public final class ModuleLoader implements CoreModule
{
HandlerList.unregisterAll((Listener) module);
}
- String[] commands = getAllHooks(module).toArray(new String[] {});
- CommandManager.unregisterAll(commands);
+ CommandManager.unregisterAllWithFallback(module.getClass().getSimpleName());
try
{
URLClassLoader loader = loaders.get(module);
@@ -387,19 +385,6 @@ public final class ModuleLoader implements CoreModule
}
}
- private static ArrayList<String> getAllHooks(Module module)
- {
- ArrayList<String> commands = new ArrayList<>();
- for (Method m : module.getClass().getMethods())
- {
- Command cmd = m.getDeclaredAnnotation(Command.class);
- if (cmd == null)
- continue;
- commands.add(cmd.hook());
- }
- return commands;
- }
-
@Command(hook = "load")
public boolean loadModule(CommandSender sender, String name)
{