From 418fbabcc81e47bb4e62082c64fedbb7a54fa5f0 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 24 Dec 2015 15:46:48 +0100 Subject: [PATCH] Fix #376 Check not to show alternatives for base command - Fix wrong assumption in HelpCommand that the incoming arguments size always corresponds to the label count of the mapped command --- .../java/fr/xephi/authme/command/executable/HelpCommand.java | 3 ++- src/main/java/fr/xephi/authme/command/help/HelpProvider.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java b/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java index 793803e59..a41ffb8d1 100644 --- a/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java @@ -43,8 +43,9 @@ public class HelpCommand extends ExecutableCommand { } } + int mappedCommandLevel = foundCommandResult.getCommandDescription().getLabelCount(); PermissionsManager permissionsManager = Wrapper.getInstance().getAuthMe().getPermissionsManager(); - List lines = arguments.size() == 1 + List lines = (mappedCommandLevel == 1) ? HelpProvider.printHelp(foundCommandResult, HelpProvider.SHOW_CHILDREN) : HelpProvider.printHelp(foundCommandResult, sender, permissionsManager, HelpProvider.ALL_OPTIONS); for (String line : lines) { diff --git a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java index 37bbb9e5c..a36039b85 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java @@ -112,7 +112,7 @@ public final class HelpProvider { private static void printAlternatives(CommandDescription command, List correctLabels, List lines) { // TODO ljacqu 20151219: Need to show alternatives for base labels too? E.g. /r for /register - if (command.getLabels().size() <= 1) { + if (command.getLabels().size() <= 1 || correctLabels.size() <= 1) { return; }