From 048518dc496931df8055530b0aacd440c4c8bec8 Mon Sep 17 00:00:00 2001 From: Taah Date: Thu, 5 May 2022 19:13:47 -0700 Subject: [PATCH] properly unregister module cmds --- server/src/main/java/dev/plex/module/ModuleManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/main/java/dev/plex/module/ModuleManager.java b/server/src/main/java/dev/plex/module/ModuleManager.java index 003a517..24c0115 100644 --- a/server/src/main/java/dev/plex/module/ModuleManager.java +++ b/server/src/main/java/dev/plex/module/ModuleManager.java @@ -17,6 +17,7 @@ import java.util.Arrays; import java.util.List; import lombok.Getter; import org.apache.logging.log4j.LogManager; +import org.bukkit.command.SimpleCommandMap; import org.bukkit.configuration.file.YamlConfiguration; @Getter @@ -119,6 +120,14 @@ public class ModuleManager { module.unregisterCommand(plexCommand); Plex.get().getServer().getCommandMap().getKnownCommands().remove(plexCommand.getName()); + plexCommand.unregister(Plex.get().getServer().getCommandMap()); + try + { + Plex.get().getServer().getCommandMap().getCommand(plexCommand.getName()).unregister(Plex.get().getServer().getCommandMap()); + } catch (Exception ignored) + { + + } plexCommand.getAliases().forEach(alias -> Plex.get().getServer().getCommandMap().getKnownCommands().remove(alias)); }); module.getListeners().stream().toList().forEach(module::unregisterListener);