Change ExecutableCommand interface (wip – doesn't compile)

- Change interface to use (CommandSender, List<String> arguments)
- Use CommandArgumentDescription#name instead of "label" (to prevent confusion between command labels and arguments)
- Simplify command difference computation in CommandHandler (no longer consider argument difference)
This commit is contained in:
ljacqu
2015-12-12 11:39:19 +01:00
parent 2f153fb85c
commit eecad80748
39 changed files with 249 additions and 517 deletions
@@ -69,7 +69,7 @@ public class HelpPrinter {
for (CommandArgumentDescription arg : command.getArguments()) {
// Create a string builder to build the syntax in
StringBuilder argString = new StringBuilder();
argString.append(" " + ChatColor.YELLOW + ChatColor.ITALIC + arg.getLabel() + " : " + ChatColor.WHITE + arg.getDescription());
argString.append(" " + ChatColor.YELLOW + ChatColor.ITALIC + arg.getName() + " : " + ChatColor.WHITE + arg.getDescription());
// Suffix a note if the command is optional
if (arg.isOptional())
@@ -29,6 +29,13 @@ public class HelpProvider {
showHelp(sender, reference, helpQuery, true, true, true, true, true, true);
}
public static void showHelp(CommandSender sender, CommandParts reference, CommandParts helpQuery,
boolean showCommand, boolean showDescription, boolean showArguments,
boolean showPermissions, boolean showAlternatives, boolean showCommands) {
showHelp(sender, reference.getList(), helpQuery.getList(), showCommand, showDescription, showArguments,
showPermissions, showAlternatives, showCommands);
}
/**
* Show help for a specific command.
*
@@ -42,7 +49,9 @@ public class HelpProvider {
* @param showAlternatives True to show the command alternatives.
* @param showCommands True to show the child commands.
*/
public static void showHelp(CommandSender sender, CommandParts reference, CommandParts helpQuery, boolean showCommand, boolean showDescription, boolean showArguments, boolean showPermissions, boolean showAlternatives, boolean showCommands) {
public static void showHelp(CommandSender sender, List<String> reference, List<String> helpQuery,
boolean showCommand, boolean showDescription, boolean showArguments,
boolean showPermissions, boolean showAlternatives, boolean showCommands) {
// Find the command for this help query, one with and one without a prefixed base command
FoundCommandResult result = AuthMe.getInstance().getCommandHandler().findCommand(new CommandParts(helpQuery.getList()));
@@ -77,7 +86,7 @@ public class HelpProvider {
}
// Get the proper command reference to use for the help page
CommandParts commandReference = command.getCommandReference(result.getQueryReference());
CommandParts commandReference = command.getCommandReference(result.getLabels());
// Get the base command
String baseCommand = commandReference.get(0);
@@ -73,8 +73,8 @@ public final class HelpSyntaxHelper {
private static String formatArgument(CommandArgumentDescription argument) {
if (argument.isOptional()) {
return " [" + argument.getLabel() + "]";
return " [" + argument.getName() + "]";
}
return " <" + argument.getLabel() + ">";
return " <" + argument.getName() + ">";
}
}