    001package co.aikar.commands;
    002
    003import com.google.common.collect.HashMultimap;
    004import com.google.common.collect.SetMultimap;
    005
    006import java.util.ArrayList;
    007import java.util.List;
    008
    009public class JDARootCommand implements RootCommand {
    010
    011    private final String name;
    012    boolean isRegistered = false;
    013    private JDACommandManager manager;
    014    private BaseCommand defCommand;
    015    private SetMultimap<String, RegisteredCommand> subCommands = HashMultimap.create();
    016    private List<BaseCommand> children = new ArrayList<>();
    017
    018    JDARootCommand(JDACommandManager manager, String name) {
    019        this.manager = manager;
    020        this.name = name;
    021    }
    022
    023    @Override
    024
    025    public void addChild(BaseCommand command) {
    026        if (this.defCommand == null || !command.subCommands.get(BaseCommand.DEFAULT).isEmpty()) {
    027            this.defCommand = command;
    028        }
    029        addChildShared(this.children, this.subCommands, command);
    030    }
    031
    032    @Override
    033    public CommandManager getManager() {
    034        return this.manager;
    035    }
    036
    037    @Override
    038    public SetMultimap<String, RegisteredCommand> getSubCommands() {
    039        return this.subCommands;
    040    }
    041
    042    @Override
    043    public List<BaseCommand> getChildren() {
    044        return this.children;
    045    }
    046
    047    @Override
    048    public String getCommandName() {
    049        return this.name;
    050    }
    051
    052    @Override
    053    public BaseCommand getDefCommand() {
    054        return defCommand;
    055    }
    056
    057}