public static void unregisterCommand(Command command, CommandMap commandMap) { try { command.unregister(commandMap); HashMap<String, Command> knownCommands = getKnownCommands(commandMap); if (knownCommands != null) { knownCommands.remove(command.getName()); for (String alias : command.getAliases()) { knownCommands.remove(alias); } } } catch (Exception ex) { TFM_Log.severe(ex); } }
/** * Unregisters a command from the server. * * <p>After a command has been unregistered, it will no longer be able to be executed. * * @param command The command to unregister. * @param commandMap The commandMap to unregister the command from. */ public static void unregisterCommand(Command command, CommandMap commandMap) { command.unregister(commandMap); HashMap<String, Command> knownCommands = getKnownCommands(commandMap); if (knownCommands == null) { return; } knownCommands.remove(command.getName()); for (String alias : command.getAliases()) { knownCommands.remove(alias); } }
public void reset() { SimpleCommandMap cmap = MagicStuff.getCommandMap(); Map<String, org.bukkit.command.Command> rcmap = MagicStuff.getKnownCommandsRawMap(); commandMap.clear(); if (cmap == null) { System.err.println("Command support failed to initialize!"); return; } for (org.bukkit.command.Command cmd : bukkitCommands) { rcmap.remove(cmd.getName()); cmd.unregister(cmap); } bukkitCommands.clear(); }