public synchronized void clearCommands() { for (Map.Entry<String, Command> entry : knownCommands.entrySet()) { entry.getValue().unregister(this); } knownCommands.clear(); setDefaultCommands(); }
@Override public boolean unregister(MCCommandMap map) { return cmd.unregister(((BukkitMCCommandMap) map).scm); }
public synchronized void clearCommands() { for (Map.Entry<String, Command> entry : knownCommands.entrySet()) { entry.getValue().unregister(this); } knownCommands.clear(); setDefaultCommands(); }
/** * Unregisters a CommandExecutor with the server * * @param command the command instance * @param <T> the command executor class type * @return the command executor */ @Nonnull public static <T extends CommandExecutor> T unregisterCommand(@Nonnull T command) { CommandMap map = getCommandMap(); try { //noinspection unchecked Map<String, Command> knownCommands = (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(map); Iterator<Command> iterator = knownCommands.values().iterator(); while (iterator.hasNext()) { Command cmd = iterator.next(); if (cmd instanceof PluginCommand) { CommandExecutor executor = ((PluginCommand) cmd).getExecutor(); if (command == executor) { cmd.unregister(map); iterator.remove(); } } } } catch (Exception e) { throw new RuntimeException("Could not unregister command", e); } return command; }
/** * Unregisters a CommandExecutor with the server * * @param command the command instance * @param <T> the command executor class type * @return the command executor */ @Nonnull public static <T extends CommandExecutor> T unregisterCommand(@Nonnull T command) { CommandMap map = getCommandMap(); try { //noinspection unchecked Map<String, Command> knownCommands = (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(map); Iterator<Command> iterator = knownCommands.values().iterator(); while (iterator.hasNext()) { Command cmd = iterator.next(); if (cmd instanceof PluginCommand) { CommandExecutor executor = ((PluginCommand) cmd).getExecutor(); if (command == executor) { cmd.unregister(map); iterator.remove(); } } } } catch (Exception e) { throw new RuntimeException("Could not unregister command", e); } return command; }
if (oldCommand instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) oldCommand).getPlugin() == this.plugin) { knownCommands.remove(commandName); oldCommand.unregister(commandMap); } else if (oldCommand != null && force) { knownCommands.remove(commandName); String[] split = ACFPatterns.COLON.split(key, 2); if (split.length > 1) { oldCommand.unregister(commandMap); oldCommand.setLabel(split[0] + ":" + command.getName()); oldCommand.register(commandMap);