Updating help command

This commit is contained in:
sekwah41 2018-02-01 22:09:54 +00:00 committed by Sekwah
parent 442c129e1b
commit 02ddd1ebf6

View File

@ -61,7 +61,7 @@ public class CommandWithSubCommands implements CommandTemplate {
if(this.subCommandRegistry.isArgRegistered(subCommand)) { if(this.subCommandRegistry.isArgRegistered(subCommand)) {
sender.sendMessage(Lang.translateInsertVariablesColor("command.help.subcommandheader", sender.sendMessage(Lang.translateInsertVariablesColor("command.help.subcommandheader",
commandExecuted.substring(0,1).toUpperCase() + commandExecuted.substring(1).toLowerCase(), subCommand)); 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 { else {
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1])); sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1]));
@ -109,14 +109,21 @@ public class CommandWithSubCommands implements CommandTemplate {
@Override @Override
public List<String> onTabComplete(CommandSenderContainer sender, String[] args) { public List<String> onTabComplete(CommandSenderContainer sender, String[] args) {
if(args.length > 1) { if(args.length > 1) {
for (String subCommandName : this.subCommandRegistry.getSubCommands()) { if(args[0].equalsIgnoreCase("help")) {
if (subCommandName.equalsIgnoreCase(args[0])) { List<String> allowedCommands = new ArrayList<>();
SubCommand subCommand = this.getSubCommand(subCommandName); allowedCommands.addAll(this.subCommandRegistry.getSubCommands());
if(subCommand.hasPermission(sender)) { Collections.sort(allowedCommands);
this.getSubCommand(subCommandName).onTabComplete(sender, args); return allowedCommands;
} }
else { else {
return null; 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"); allowedCommands.add("help");
} }
Collections.sort(allowedCommands); Collections.sort(allowedCommands);