mirror of
https://github.com/aikar/commands.git
synced 2026-06-17 12:40:37 +00:00
Bungee: Implement getDefCommand & command unregistration (#71)
* Implement getDefCommand * Implement command unregistration for Bungee * Remove accidental star imports
This commit is contained in:
committed by
Daniel Ennis
parent
b5c368a64b
commit
1fbdfb19c9
@@ -26,15 +26,13 @@ package co.aikar.commands;
|
||||
import co.aikar.commands.apachecommonslang.ApacheCommonsExceptionUtil;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -99,6 +97,28 @@ public class BungeeCommandManager extends CommandManager<CommandSender, ChatColo
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterCommand(BaseCommand command) {
|
||||
for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) {
|
||||
String commandName = entry.getKey().toLowerCase();
|
||||
BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue();
|
||||
if (bungeeCommand.isRegistered) {
|
||||
unregisterCommand(bungeeCommand);
|
||||
}
|
||||
bungeeCommand.isRegistered = false;
|
||||
registeredCommands.remove(commandName);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterCommand(BungeeRootCommand command) {
|
||||
this.plugin.getProxy().getPluginManager().unregisterCommand(command);
|
||||
}
|
||||
|
||||
public void unregisterCommands() {
|
||||
for (Map.Entry<String, BungeeRootCommand> entry : registeredCommands.entrySet()) {
|
||||
unregisterCommand(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRegisteredCommands() {
|
||||
return !registeredCommands.isEmpty();
|
||||
|
||||
@@ -29,7 +29,10 @@ import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class BungeeRootCommand extends Command implements RootCommand, TabExecutor {
|
||||
|
||||
@@ -85,4 +88,9 @@ public class BungeeRootCommand extends Command implements RootCommand, TabExecut
|
||||
this.children.forEach(child -> completions.addAll(child.tabComplete(sender, alias, args)));
|
||||
return new ArrayList<>(completions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseCommand getDefCommand() {
|
||||
return defCommand;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user