本文整理了Java中org.bukkit.command.Command.unregister()
方法的一些代码示例,展示了Command.unregister()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Command.unregister()
方法的具体详情如下:
包路径:org.bukkit.command.Command
类名称:Command
方法名:unregister
[英]Unregisters this command from the passed CommandMap applying any outstanding changes
[中]应用任何未完成的更改,从传递的CommandMap中注销此命令
代码示例来源:origin: Bukkit/Bukkit
public synchronized void clearCommands() {
for (Map.Entry<String, Command> entry : knownCommands.entrySet()) {
entry.getValue().unregister(this);
}
knownCommands.clear();
setDefaultCommands();
}
代码示例来源:origin: EngineHub/CommandHelper
@Override
public boolean unregister(MCCommandMap map) {
return cmd.unregister(((BukkitMCCommandMap) map).scm);
}
代码示例来源:origin: SpigotMC/Spigot-API
public synchronized void clearCommands() {
for (Map.Entry<String, Command> entry : knownCommands.entrySet()) {
entry.getValue().unregister(this);
}
knownCommands.clear();
setDefaultCommands();
}
代码示例来源:origin: lucko/helper
/**
* 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;
}
代码示例来源:origin: me.lucko/helper
/**
* 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;
}
代码示例来源:origin: aikar/commands
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);
内容来源于网络,如有侵权,请联系作者删除!