Fix label handling issues after reformatting
- Pass the correct arguments to HelpCommand - Fix minor formatting / conditional check issues
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.command.executable;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandHandler;
|
||||
import fr.xephi.authme.command.CommandUtils;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
@@ -8,12 +7,12 @@ import fr.xephi.authme.command.FoundCommandResult;
|
||||
import fr.xephi.authme.command.FoundResultStatus;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.command.FoundResultStatus.INCORRECT_ARGUMENTS;
|
||||
import static fr.xephi.authme.command.FoundResultStatus.MISSING_BASE_COMMAND;
|
||||
import static fr.xephi.authme.command.FoundResultStatus.UNKNOWN_LABEL;
|
||||
|
||||
@@ -24,7 +23,7 @@ public class HelpCommand extends ExecutableCommand {
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// TODO #306 ljacqu 20151213: Get command handler from non-static context
|
||||
CommandHandler commandHandler = AuthMe.getInstance().getCommandHandler();
|
||||
CommandHandler commandHandler = Wrapper.getInstance().getAuthMe().getCommandHandler();
|
||||
FoundCommandResult foundCommandResult = commandHandler.mapPartsToCommand(arguments);
|
||||
|
||||
// TODO ljacqu 20151213: This is essentially the same logic as in CommandHandler and we'd like to have the same
|
||||
@@ -32,20 +31,19 @@ public class HelpCommand extends ExecutableCommand {
|
||||
// success.
|
||||
FoundResultStatus resultStatus = foundCommandResult.getResultStatus();
|
||||
if (MISSING_BASE_COMMAND.equals(resultStatus)) {
|
||||
// FIXME something wrong - this error appears
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Could not get base command");
|
||||
return;
|
||||
} else if (INCORRECT_ARGUMENTS.equals(resultStatus) || UNKNOWN_LABEL.equals(resultStatus)) {
|
||||
if (foundCommandResult.getCommandDescription() != null) {
|
||||
} else if (UNKNOWN_LABEL.equals(resultStatus)) {
|
||||
if (foundCommandResult.getCommandDescription() == null) {
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Unknown command");
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.GOLD + "Assuming " + ChatColor.WHITE + "/"
|
||||
+ CommandUtils.labelsToString(foundCommandResult.getCommandDescription().getLabels()));
|
||||
sender.sendMessage(ChatColor.GOLD + "Assuming " + ChatColor.WHITE
|
||||
+ CommandUtils.constructCommandPath(foundCommandResult.getCommandDescription()));
|
||||
}
|
||||
}
|
||||
|
||||
PermissionsManager permissionsManager = AuthMe.getInstance().getPermissionsManager();
|
||||
PermissionsManager permissionsManager = Wrapper.getInstance().getAuthMe().getPermissionsManager();
|
||||
List<String> lines = arguments.size() == 1
|
||||
? HelpProvider.printHelp(foundCommandResult, HelpProvider.SHOW_CHILDREN)
|
||||
: HelpProvider.printHelp(foundCommandResult, sender, permissionsManager, HelpProvider.ALL_OPTIONS);
|
||||
|
||||
Reference in New Issue
Block a user