use of fr.xephi.authme.command.FoundCommandResult in project AuthMeReloaded by AuthMe.
the class EmailBaseCommand method executeCommand.
@Override
public void executeCommand(CommandSender sender, List<String> arguments) {
FoundCommandResult result = commandMapper.mapPartsToCommand(sender, Collections.singletonList("email"));
helpProvider.outputHelp(sender, result, HelpProvider.SHOW_CHILDREN);
}
use of fr.xephi.authme.command.FoundCommandResult 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);
}
}
use of fr.xephi.authme.command.FoundCommandResult in project AuthMeReloaded by AuthMe.
the class HelpProviderTest method shouldShowCommandSyntaxWithCorrectLabels.
/**
* Since command parts may be mapped to a command description with labels that don't completely correspond to it,
* (e.g. suggest "register command" for /authme ragister), we need to check the labels and construct a correct list
*/
@Test
public void shouldShowCommandSyntaxWithCorrectLabels() {
// given
CommandDescription command = getCommandWithLabel(commands, "authme", "register");
FoundCommandResult result = newFoundResult(command, Arrays.asList("authme", "ragister"));
// when
helpProvider.outputHelp(sender, result, SHOW_COMMAND);
// then
List<String> lines = getLines(sender);
assertThat(lines, hasSize(2));
assertThat(lines.get(0), containsString("Header"));
assertThat(lines.get(1), containsString("Command: /authme register <password> <confirmation>"));
}
use of fr.xephi.authme.command.FoundCommandResult in project AuthMeReloaded by AuthMe.
the class HelpProviderTest method shouldShowSpecifyIfArgumentIsOptional.
@Test
public void shouldShowSpecifyIfArgumentIsOptional() {
// given
CommandDescription command = getCommandWithLabel(commands, "email");
FoundCommandResult result = newFoundResult(command, Collections.singletonList("email"));
// when
helpProvider.outputHelp(sender, result, SHOW_ARGUMENTS);
// then
List<String> lines = getLines(sender);
assertThat(lines, hasSize(3));
assertThat(lines.get(2), containsString("player: 'player' argument description (Optional)"));
}
use of fr.xephi.authme.command.FoundCommandResult in project AuthMeReloaded by AuthMe.
the class HelpProviderTest method shouldNotShowAnythingIfCommandHasNoArguments.
/** Verifies that the "Arguments:" line is not shown if the command has no arguments. */
@Test
public void shouldNotShowAnythingIfCommandHasNoArguments() {
// given
CommandDescription command = getCommandWithLabel(commands, "authme");
FoundCommandResult result = newFoundResult(command, Collections.singletonList("authme"));
// when
helpProvider.outputHelp(sender, result, SHOW_ARGUMENTS);
// then
List<String> lines = getLines(sender);
// only has the help banner
assertThat(lines, hasSize(1));
}
Aggregations