mirror of
https://github.com/aikar/commands.git
synced 2026-06-02 23:32:17 +00:00
Replace a bit of code duplication and misc cleanup
This commit is contained in:
@@ -89,13 +89,13 @@ public class SpongeCommandManager extends CommandManager {
|
||||
command.onRegister(this);
|
||||
|
||||
for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) {
|
||||
String key = entry.getKey().toLowerCase();
|
||||
SpongeRootCommand value = (SpongeRootCommand) entry.getValue();
|
||||
if (!value.isRegistered) {
|
||||
Sponge.getCommandManager().register(this.plugin, value, value.name);
|
||||
String commandName = entry.getKey().toLowerCase();
|
||||
SpongeRootCommand spongeCommand = (SpongeRootCommand) entry.getValue();
|
||||
if (!spongeCommand.isRegistered) {
|
||||
Sponge.getCommandManager().register(this.plugin, spongeCommand, commandName);
|
||||
}
|
||||
value.isRegistered = true;
|
||||
registeredCommands.put(key, value);
|
||||
spongeCommand.isRegistered = true;
|
||||
registeredCommands.put(commandName, spongeCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,11 @@ public class SpongeRootCommand implements CommandCallable, RootCommand {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult process(CommandSource source, String arguments) throws CommandException {
|
||||
if(this.execute(new SpongeCommandIssuer(manager, source), this.name, arguments.split(" "))) {
|
||||
@@ -112,23 +117,8 @@ public class SpongeRootCommand implements CommandCallable, RootCommand {
|
||||
public void addChild(BaseCommand command) {
|
||||
if (this.defCommand == null || !command.subCommands.get("__default").isEmpty()) {
|
||||
this.defCommand = command;
|
||||
//this.setDescription(command.getDescription());
|
||||
//this.setUsage(command.getUsage());
|
||||
//this.setAliases(command.getAliases());
|
||||
}
|
||||
command.subCommands.keySet().forEach(key -> {
|
||||
if (key.equals(BaseCommand.DEFAULT) || key.equals(BaseCommand.UNKNOWN)) {
|
||||
return;
|
||||
}
|
||||
BaseCommand regged = this.subCommands.get(key);
|
||||
if (regged != null) {
|
||||
this.manager.log(LogLevel.ERROR, "ACF Error: " + command.getName() + " registered subcommand " + key + " for root command " + this.name + " - but it is already defined in " + regged.getName());
|
||||
this.manager.log(LogLevel.ERROR, "2 subcommands of the same prefix may not be spread over 2 different classes. Ignoring this.");
|
||||
return;
|
||||
}
|
||||
this.subCommands.put(key, command);
|
||||
});
|
||||
this.children.add(command);
|
||||
addChildShared(this.children, this.subCommands, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user