Fix the Bukkit force unregister command logic

The previous made the command think it was fully unregistered,
instead of just removing just the conflicting entry.
This commit is contained in:
Aikar
2017-07-19 22:56:22 -04:00
parent d76d796feb
commit 829d79a737
@@ -150,10 +150,20 @@ public class BukkitCommandManager extends CommandManager<CommandSender, ChatColo
String commandName = entry.getKey().toLowerCase();
BukkitRootCommand bukkitCommand = (BukkitRootCommand) entry.getValue();
if (!bukkitCommand.isRegistered) {
if(force) {
if(knownCommands.containsKey(commandName)) {
commandMap.getCommand(commandName).unregister(commandMap);
knownCommands.remove(commandName);
if (force && knownCommands.containsKey(commandName)) {
Command oldCommand = commandMap.getCommand(commandName);
knownCommands.remove(commandName);
for (Map.Entry<String, Command> ce : knownCommands.entrySet()) {
String key = ce.getKey();
Command value = ce.getValue();
if (key.contains(":") && oldCommand.equals(value)) {
String[] split = ACFPatterns.COLON.split(key, 2);
if (split.length > 1) {
oldCommand.unregister(commandMap);
oldCommand.setLabel(split[0] + ":" + command.getName());
oldCommand.register(commandMap);
}
}
}
}
commandMap.register(commandName, plugin, bukkitCommand);