No longer require true/false for the -m.

This commit is contained in:
graywolf336 2013-12-19 09:19:55 -06:00
parent 500c2abd51
commit 5f2fcd9027
3 changed files with 11 additions and 10 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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());
}
}