Search in sources :

Example 1 with FoundResultStatus

use of fr.xephi.authme.command.FoundResultStatus in project AuthMeReloaded by AuthMe.

the class HelpCommand method executeCommand.

// Convention: arguments is not the actual invoked arguments but the command that was invoked,
// e.g. "/authme help register" would typically be arguments = [register], but here we pass [authme, register]
@Override
public void executeCommand(CommandSender sender, List<String> arguments) {
    FoundCommandResult result = commandMapper.mapPartsToCommand(sender, arguments);
    FoundResultStatus resultStatus = result.getResultStatus();
    if (MISSING_BASE_COMMAND.equals(resultStatus)) {
        sender.sendMessage(ChatColor.DARK_RED + "Could not get base command");
        return;
    } else if (UNKNOWN_LABEL.equals(resultStatus)) {
        if (result.getCommandDescription() == null) {
            sender.sendMessage(ChatColor.DARK_RED + "Unknown command");
            return;
        } else {
            sender.sendMessage(ChatColor.GOLD + "Assuming " + ChatColor.WHITE + CommandUtils.constructCommandPath(result.getCommandDescription()));
        }
    }
    int mappedCommandLevel = result.getCommandDescription().getLabelCount();
    if (mappedCommandLevel == 1) {
        helpProvider.outputHelp(sender, result, SHOW_COMMAND | SHOW_DESCRIPTION | SHOW_CHILDREN | SHOW_ALTERNATIVES);
    } else {
        helpProvider.outputHelp(sender, result, ALL_OPTIONS);
    }
}
Also used : FoundCommandResult(fr.xephi.authme.command.FoundCommandResult) FoundResultStatus(fr.xephi.authme.command.FoundResultStatus)

Aggregations

FoundCommandResult (fr.xephi.authme.command.FoundCommandResult)1 FoundResultStatus (fr.xephi.authme.command.FoundResultStatus)1