0

Move to Master #8

Merged
Minenash merged 24 commits from gradle into master 2019-02-08 16:31:21 +00:00
Showing only changes of commit ae5494f203 - Show all commits

View File

@ -5,7 +5,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Method;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; 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. /** The module loader, mother of all modules. Responsible for loading and taking care of all modules.
* *
* @author Pepich */ * @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 public final class ModuleLoader implements CoreModule
{ {
private static ModuleLoader instance; private static ModuleLoader instance;
@ -370,8 +369,7 @@ public final class ModuleLoader implements CoreModule
{ {
HandlerList.unregisterAll((Listener) module); HandlerList.unregisterAll((Listener) module);
} }
String[] commands = getAllHooks(module).toArray(new String[] {}); CommandManager.unregisterAllWithFallback(module.getClass().getSimpleName());
CommandManager.unregisterAll(commands);
try try
{ {
URLClassLoader loader = loaders.get(module); 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") @Command(hook = "load")
public boolean loadModule(CommandSender sender, String name) public boolean loadModule(CommandSender sender, String name)
{ {