From c9b66183ded2b1d22e0e1affe1b2b1f001453a59 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 18 Feb 2017 15:56:08 +0100 Subject: [PATCH] Fix command mapping for /authme:unregister etc. --- .../fr/xephi/authme/command/CommandMapper.java | 3 +++ .../xephi/authme/command/CommandMapperTest.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/fr/xephi/authme/command/CommandMapper.java b/src/main/java/fr/xephi/authme/command/CommandMapper.java index c5cf91c0f..33003c3ae 100644 --- a/src/main/java/fr/xephi/authme/command/CommandMapper.java +++ b/src/main/java/fr/xephi/authme/command/CommandMapper.java @@ -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; diff --git a/src/test/java/fr/xephi/authme/command/CommandMapperTest.java b/src/test/java/fr/xephi/authme/command/CommandMapperTest.java index dd7bad6e4..3a23cdc8c 100644 --- a/src/test/java/fr/xephi/authme/command/CommandMapperTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandMapperTest.java @@ -290,6 +290,21 @@ public class CommandMapperTest { assertThat(result.getArguments(), contains(parts.get(2))); } + @Test + public void shouldSupportAuthMePrefix() { + // given + List 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() {