From 02ddd1ebf697b45186d8aaf7635c4efbff614098 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Thu, 1 Feb 2018 22:09:54 +0000 Subject: [PATCH] Updating help command --- .../core/commands/CommandWithSubCommands.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java b/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java index 112dfc16..f10deb2d 100644 --- a/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java +++ b/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java @@ -61,7 +61,7 @@ public class CommandWithSubCommands implements CommandTemplate { if(this.subCommandRegistry.isArgRegistered(subCommand)) { sender.sendMessage(Lang.translateInsertVariablesColor("command.help.subcommandheader", commandExecuted.substring(0,1).toUpperCase() + commandExecuted.substring(1).toLowerCase(), subCommand)); - sender.sendMessage("\u00A7e" + this.getSubCommand(subCommand).getDetailedHelpText()); + sender.sendMessage("\u00A77" + this.getSubCommand(subCommand).getDetailedHelpText()); } else { sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1])); @@ -109,14 +109,21 @@ public class CommandWithSubCommands implements CommandTemplate { @Override public List onTabComplete(CommandSenderContainer sender, String[] args) { if(args.length > 1) { - for (String subCommandName : this.subCommandRegistry.getSubCommands()) { - if (subCommandName.equalsIgnoreCase(args[0])) { - SubCommand subCommand = this.getSubCommand(subCommandName); - if(subCommand.hasPermission(sender)) { - this.getSubCommand(subCommandName).onTabComplete(sender, args); - } - else { - return null; + if(args[0].equalsIgnoreCase("help")) { + List allowedCommands = new ArrayList<>(); + allowedCommands.addAll(this.subCommandRegistry.getSubCommands()); + Collections.sort(allowedCommands); + return allowedCommands; + } + else { + for (String subCommandName : this.subCommandRegistry.getSubCommands()) { + if (subCommandName.equalsIgnoreCase(args[0])) { + SubCommand subCommand = this.getSubCommand(subCommandName); + if (subCommand.hasPermission(sender)) { + this.getSubCommand(subCommandName).onTabComplete(sender, args); + } else { + return null; + } } } } @@ -131,7 +138,7 @@ public class CommandWithSubCommands implements CommandTemplate { } } } - if(args.length == 0) { + if(args.length == 1) { allowedCommands.add("help"); } Collections.sort(allowedCommands);