From 5f2fcd9027af85320f0acbda48628dda8f826af9 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Thu, 19 Dec 2013 09:19:55 -0600 Subject: [PATCH] No longer require true/false for the -m. --- .../jail/command/commands/JailCommand.java | 3 ++- .../jail/command/parameters/JailParameters.java | 4 ++-- .../com/graywolf336/jail/TestCommandParams.java | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java b/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java index fb9fb38..5ddc8ad 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java +++ b/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java @@ -27,7 +27,8 @@ public class JailCommand implements Command { try { new JCommander(params, args); }catch(ParameterException e) { - return false; + sender.sendMessage(e.getMessage()); + return true; } diff --git a/src/main/java/com/graywolf336/jail/command/parameters/JailParameters.java b/src/main/java/com/graywolf336/jail/command/parameters/JailParameters.java index cce6c40..cd84c8f 100644 --- a/src/main/java/com/graywolf336/jail/command/parameters/JailParameters.java +++ b/src/main/java/com/graywolf336/jail/command/parameters/JailParameters.java @@ -9,7 +9,7 @@ import com.beust.jcommander.Parameter; * Contains all the parameters from the jail command. * * @author graywolf336 - * @version 1.0.0 + * @version 1.0.1 * @since 3.0.0 */ public class JailParameters { @@ -28,7 +28,7 @@ public class JailParameters { @Parameter(names = { "-c", "-cell" }, description = "The cell in the jail we are sending them to.") private String cell = ""; - @Parameter(names = { "-m", "-muted" }, description = "Whether they can talk or not.", arity = 1) + @Parameter(names = { "-m", "-muted" }, description = "Whether they can talk or not.") private boolean muted = false; @Parameter(names = { "-r", "-reason" }, description = "The reason this player is being jailed for.", variableArity = true) diff --git a/src/test/java/test/java/com/graywolf336/jail/TestCommandParams.java b/src/test/java/test/java/com/graywolf336/jail/TestCommandParams.java index a110795..cec6c5f 100644 --- a/src/test/java/test/java/com/graywolf336/jail/TestCommandParams.java +++ b/src/test/java/test/java/com/graywolf336/jail/TestCommandParams.java @@ -13,14 +13,14 @@ public class TestCommandParams { public void TestJailCommand() { JailParameters jail = new JailParameters(); //"/jail [-p name] (-t time) (-j JailName) (-c CellName) (-m Muted) (-r A reason for jailing)" - String[] params = { "-p", "graywolf336", "-t", "30", "-j", "den", "-c", "cell_01", "-m", "true", "-r", "He", "was", "a", "very", "bad", "boy." }; + String[] params = { "-p", "graywolf336", "-t", "30", "-j", "den", "-c", "cell_01", "-m", "-r", "He", "was", "a", "very", "bad", "boy." }; new JCommander(jail, params); - Assert.assertEquals("The player is not the one we provided.", jail.player(), "graywolf336"); - Assert.assertEquals("The time doesn't match what we gave.", jail.time(), "30"); - Assert.assertEquals("The jail is not the one we specified.", jail.jail(), "den"); - Assert.assertEquals("The cell doesn't match up.", jail.cell(), "cell_01"); - Assert.assertEquals("The muted is not true.", jail.muted(), true); - Assert.assertEquals("Jailed reason didn't match up.", jail.reason(), "He was a very bad boy."); + Assert.assertEquals("The player is not the one we provided.", "graywolf336", jail.player()); + Assert.assertEquals("The time doesn't match what we gave.", "30", jail.time()); + Assert.assertEquals("The jail is not the one we specified.", "den", jail.jail()); + Assert.assertEquals("The cell doesn't match up.", "cell_01", jail.cell()); + Assert.assertEquals("The muted is false.", true, jail.muted()); + Assert.assertEquals("Jailed reason didn't match up.", "He was a very bad boy.", jail.reason()); } }