Fix command mapping for /authme:unregister etc.
This commit is contained in:
parent
e3426cd731
commit
c9b66183de
@ -123,6 +123,9 @@ public class CommandMapper {
|
|||||||
|
|
||||||
private CommandDescription getBaseCommand(String label) {
|
private CommandDescription getBaseCommand(String label) {
|
||||||
String baseLabel = label.toLowerCase();
|
String baseLabel = label.toLowerCase();
|
||||||
|
if (baseLabel.startsWith("authme:")) {
|
||||||
|
baseLabel = baseLabel.substring("authme:".length());
|
||||||
|
}
|
||||||
for (CommandDescription command : baseCommands) {
|
for (CommandDescription command : baseCommands) {
|
||||||
if (command.hasLabel(baseLabel)) {
|
if (command.hasLabel(baseLabel)) {
|
||||||
return command;
|
return command;
|
||||||
|
|||||||
@ -290,6 +290,21 @@ public class CommandMapperTest {
|
|||||||
assertThat(result.getArguments(), contains(parts.get(2)));
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnExecutableCommandClasses() {
|
public void shouldReturnExecutableCommandClasses() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user