default RegisteredCommand getDefaultRegisteredCommand() { BaseCommand defCommand = this.getDefCommand(); if (defCommand != null) { return defCommand.getDefaultRegisteredCommand(); } return null; }
default BaseCommand getBaseCommand(String[] args) { BaseCommand command = getDefCommand(); for (int i = args.length; i >= 0; i--) { String checkSub = ApacheCommonsLangUtil.join(args, " ", 0, i).toLowerCase(); Set<RegisteredCommand> registeredCommands = getSubCommands().get(checkSub); if (!registeredCommands.isEmpty()) { command = registeredCommands.iterator().next().scope; break; } } return command; }
default String getDescription() { final RegisteredCommand cmd = this.getDefaultRegisteredCommand(); if (cmd != null) { return cmd.getHelpText(); } BaseCommand defCommand = getDefCommand(); if (defCommand != null && defCommand.description != null) { return defCommand.description; } return ""; }
public CommandHelp(CommandManager manager, RootCommand rootCommand, CommandIssuer issuer) { this.manager = manager; this.issuer = issuer; this.perPage = manager.defaultHelpPerPage; this.commandPrefix = manager.getCommandPrefix(issuer); this.commandName = rootCommand.getCommandName(); SetMultimap<String, RegisteredCommand> subCommands = rootCommand.getSubCommands(); Set<RegisteredCommand> seen = new HashSet<>(); if (!rootCommand.getDefCommand().hasHelpCommand) { helpEntries.add(new HelpEntry(this, rootCommand.getDefaultRegisteredCommand())); seen.add(rootCommand.getDefaultRegisteredCommand()); } subCommands.entries().forEach(e -> { String key = e.getKey(); if (key.equals(BaseCommand.DEFAULT) || key.equals(BaseCommand.CATCHUNKNOWN)) { return; } RegisteredCommand regCommand = e.getValue(); if (!regCommand.isPrivate && regCommand.hasPermission(issuer) && !seen.contains(regCommand)) { this.helpEntries.add(new HelpEntry(this, regCommand)); seen.add(regCommand); } }); }