Fix command mapping for /authme:unregister etc.

This commit is contained in:
ljacqu 2017-02-18 15:56:08 +01:00
parent e3426cd731
commit c9b66183de
2 changed files with 18 additions and 0 deletions

View File

@ -123,6 +123,9 @@ public class CommandMapper {
private CommandDescription getBaseCommand(String label) {
String baseLabel = label.toLowerCase();
if (baseLabel.startsWith("authme:")) {
baseLabel = baseLabel.substring("authme:".length());
}
for (CommandDescription command : baseCommands) {
if (command.hasLabel(baseLabel)) {
return command;

View File

@ -290,6 +290,21 @@ public class CommandMapperTest {
assertThat(result.getArguments(), contains(parts.get(2)));
}
@Test
public void shouldSupportAuthMePrefix() {
// given
List<String> parts = asList("authme:unregister", "Betty");
CommandSender sender = mock(CommandSender.class);
given(permissionsManager.hasPermission(eq(sender), any(PermissionNode.class))).willReturn(true);
// when
FoundCommandResult result = mapper.mapPartsToCommand(sender, parts);
// then
assertThat(result.getResultStatus(), equalTo(FoundResultStatus.SUCCESS));
assertThat(result.getCommandDescription(), equalTo(getCommandWithLabel(commands, "unregister")));
}
@SuppressWarnings("unchecked")
@Test
public void shouldReturnExecutableCommandClasses() {