diff --git a/common/pom.xml b/common/pom.xml
index 6280e180..ef9d4262 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -16,5 +16,9 @@
net.cubespace
Yamler-Core
+
+ junit
+ junit
+
diff --git a/common/src/main/java/io/github/xxyy/cmdblocker/common/util/CommandHelper.java b/common/src/main/java/io/github/xxyy/cmdblocker/common/util/CommandHelper.java
index c3885253..4c1072d7 100644
--- a/common/src/main/java/io/github/xxyy/cmdblocker/common/util/CommandHelper.java
+++ b/common/src/main/java/io/github/xxyy/cmdblocker/common/util/CommandHelper.java
@@ -24,7 +24,7 @@ public static String getRawCommand(String chatMessage) {
if (spaceIndex == -1) { //If no space found
chatMessage = chatMessage.substring(1); //Just remove slash
} else { //If we have a space
- chatMessage = chatMessage.substring(1, spaceIndex - 1); //Get the first word of the message and remove slash
+ chatMessage = chatMessage.substring(1, spaceIndex); //Get the first word of the message and remove slash
}
return removeModPrefix(chatMessage); //Return the raw command name!
diff --git a/common/src/test/java/io/github/xxyy/cmdblocker/common/util/CommandHelperTest.java b/common/src/test/java/io/github/xxyy/cmdblocker/common/util/CommandHelperTest.java
new file mode 100644
index 00000000..a7c95f70
--- /dev/null
+++ b/common/src/test/java/io/github/xxyy/cmdblocker/common/util/CommandHelperTest.java
@@ -0,0 +1,24 @@
+package io.github.xxyy.cmdblocker.common.util;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests the CommandHelper class for compliance with the JavaDoc declarations
+ *
+ * @author xxyy
+ * @since 20/09/14
+ */
+public class CommandHelperTest {
+ @Test
+ public void testGetRawCommand() {
+ assertThat(CommandHelper.getRawCommand("/help"), is("help"));
+ assertThat(CommandHelper.getRawCommand("/help test"), is("help"));
+ assertThat(CommandHelper.getRawCommand("/minecraft:help"), is("help"));
+ assertThat(CommandHelper.getRawCommand("/minecraft:help test"), is("help"));
+ assertThat(CommandHelper.getRawCommand("/bukkit:help"), is("help"));
+ assertThat(CommandHelper.getRawCommand("/bukkit:help something multiple arguments wow"), is("help"));
+ }
+}
diff --git a/pom.xml b/pom.xml
index c07e6f96..c49bb90e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -122,6 +122,12 @@
Yamler-Core
2.2.3-SNAPSHOT
+
+
+ junit
+ junit
+ 4.11
+