- Add command and listener support

This commit is contained in:
Taah
2022-03-05 17:17:14 -08:00
parent 87ddf355b5
commit 69541a20b8
2 changed files with 46 additions and 0 deletions

View File

@ -89,11 +89,18 @@ public class ModuleManager {
public void disableModules() {
this.modules.forEach(module -> {
PlexLog.log("Disabling module " + module.getPlexModuleFile().getName() + " with version " + module.getPlexModuleFile().getVersion());
module.getCommands().stream().toList().forEach(plexCommand -> {
module.unregisterCommand(plexCommand);
Plex.get().getServer().getCommandMap().getKnownCommands().remove(plexCommand.getName());
plexCommand.getAliases().forEach(alias -> Plex.get().getServer().getCommandMap().getKnownCommands().remove(alias));
});
module.getListeners().forEach(module::unregisterListener);
module.disable();
});
}
public void unloadModules() {
this.disableModules();
this.modules.forEach(module -> {
try {
((URLClassLoader)module.getClass().getClassLoader()).close();