Fix the tests failing and also fix the jail command not doing anything.
This commit is contained in:
parent
58bc007b3e
commit
48a7435fbe
@ -118,7 +118,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
||||||
if(command.getName().equalsIgnoreCase("jail")) {
|
if(command.getName().equalsIgnoreCase("jail")) {
|
||||||
jh.handleCommand(jm, sender, args);
|
jh.parseCommand(jm, sender, args);
|
||||||
}else {
|
}else {
|
||||||
cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args);
|
cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args);
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,6 @@ public class JailHandler {
|
|||||||
plugin.getLogger().info("Loaded " + commands.size() + " sub-commands of /jail.");
|
plugin.getLogger().info("Loaded " + commands.size() + " sub-commands of /jail.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCommand(JailManager jm, CommandSender sender, String... args) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the given command and checks that the command is in valid form.
|
* Handles the given command and checks that the command is in valid form.
|
||||||
*
|
*
|
||||||
|
@ -19,9 +19,14 @@ public interface Jailing {
|
|||||||
public String getCell();
|
public String getCell();
|
||||||
|
|
||||||
@Option(longName={"muted", "canttalk"}, shortName="m", description = "whether the prisoner is muted or not")
|
@Option(longName={"muted", "canttalk"}, shortName="m", description = "whether the prisoner is muted or not")
|
||||||
public boolean isMuted();
|
public boolean getMuted();
|
||||||
|
|
||||||
@Option(longName={"reason"}, shortName="r", description = "the reason this player is being jailed")
|
@Option(longName={"reason"}, shortName="r", description = "the reason this player is being jailed")
|
||||||
public List<String> getReason();
|
public List<String> getReason();
|
||||||
|
|
||||||
|
public boolean isTime();
|
||||||
|
public boolean isJail();
|
||||||
|
public boolean isCell();
|
||||||
|
public boolean isMuted();
|
||||||
|
public boolean isReason();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class JailCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If the config has automatic muting, then let's set them as muted
|
//If the config has automatic muting, then let's set them as muted
|
||||||
boolean muted = params.isMuted();
|
boolean muted = params.getMuted();
|
||||||
if(jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath())) {
|
if(jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath())) {
|
||||||
muted = true;
|
muted = true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package test.java.com.graywolf336.jail;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.graywolf336.jail.command.commands.jewels.Jailing;
|
||||||
|
import com.lexicalscope.jewel.cli.CliFactory;
|
||||||
|
|
||||||
|
public class JewelCommands {
|
||||||
|
@Test
|
||||||
|
public void testJewel() {
|
||||||
|
String[] args = { "--player", "graywolf336", "-c", "testing", "-r", "This", "is", "a", "reason" };
|
||||||
|
Jailing j = CliFactory.parseArguments(Jailing.class, args);
|
||||||
|
|
||||||
|
Assert.assertEquals("graywolf336", j.getPlayer());
|
||||||
|
Assert.assertEquals("testing", j.getCell());
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(String s : j.getReason()) {
|
||||||
|
sb.append(s).append(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
|
|
||||||
|
Assert.assertEquals("This is a reason", sb.toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user