Move clearforce into clear and use -f (-force) to forcefully do it.

It does still require the permission `jail.command.jailclearforce` and
if it isn't provided then it will fall back to regular clearing.
This commit is contained in:
graywolf336 2014-07-24 23:29:53 -05:00
parent 1ea60ca106
commit cac81f0420
4 changed files with 13 additions and 40 deletions

View File

@ -14,6 +14,7 @@ Beta 3 Changes
* Lots of work on unit testing * Lots of work on unit testing
* Changed the encoding of the project in maven to utf8 * Changed the encoding of the project in maven to utf8
* Fixed the language system not copying over new values * Fixed the language system not copying over new values
* Fixed confirmations not expiring, ever
Beta 2 Changes Beta 2 Changes
=== ===

View File

@ -13,7 +13,6 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.subcommands.JailCreateCellCommand; import com.graywolf336.jail.command.subcommands.JailCreateCellCommand;
import com.graywolf336.jail.command.subcommands.JailCheckCommand; import com.graywolf336.jail.command.subcommands.JailCheckCommand;
import com.graywolf336.jail.command.subcommands.JailClearCommand; import com.graywolf336.jail.command.subcommands.JailClearCommand;
import com.graywolf336.jail.command.subcommands.JailClearForceCommand;
import com.graywolf336.jail.command.subcommands.JailCommand; import com.graywolf336.jail.command.subcommands.JailCommand;
import com.graywolf336.jail.command.subcommands.JailConfirmCommand; import com.graywolf336.jail.command.subcommands.JailConfirmCommand;
import com.graywolf336.jail.command.subcommands.JailCreateCommand; import com.graywolf336.jail.command.subcommands.JailCreateCommand;
@ -177,7 +176,6 @@ public class JailHandler {
load(JailCreateCellCommand.class); load(JailCreateCellCommand.class);
load(JailCheckCommand.class); load(JailCheckCommand.class);
load(JailClearCommand.class); load(JailClearCommand.class);
load(JailClearForceCommand.class);
load(JailCommand.class); load(JailCommand.class);
load(JailConfirmCommand.class); load(JailConfirmCommand.class);
load(JailCreateCommand.class); load(JailCreateCommand.class);

View File

@ -13,16 +13,24 @@ import com.graywolf336.jail.enums.Lang;
maxArgs = 1, maxArgs = 1,
minimumArgs = 0, minimumArgs = 0,
needsPlayer = false, needsPlayer = false,
pattern = "clear", pattern = "clear|clearforce",
permission = "jail.command.jailclear", permission = "jail.command.jailclear",
usage = "/jail clear (Jail name)" usage = "/jail clear (-f) (jail)"
) )
public class JailClearCommand implements Command { public class JailClearCommand implements Command {
// If Jail is specified unjails all the prisoners from that Jail (new feature) otherwise it unjails all the prisoners from all the jails
public boolean execute(JailManager jm, CommandSender sender, String... args) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
boolean force = false;
//Check if we need to forcefully clear something
for(String s : args)
if(s.equalsIgnoreCase("-f") || s.equalsIgnoreCase("-force"))
force = true;
if(jm.isConfirming(sender.getName())) { if(jm.isConfirming(sender.getName())) {
sender.sendMessage(Lang.ALREADY.get()); sender.sendMessage(Lang.ALREADY.get());
}else if(force && sender.hasPermission("jail.command.jailclearforce")) {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEARFORCE));
sender.sendMessage(Lang.START.get());
}else { }else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEAR)); jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEAR));
sender.sendMessage(Lang.START.get()); sender.sendMessage(Lang.START.get());

View File

@ -1,34 +0,0 @@
package com.graywolf336.jail.command.subcommands;
import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.ConfirmPlayer;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
minimumArgs = 0,
needsPlayer = false,
pattern = "clearforce|cf",
permission = "jail.command.jailclearforce",
usage = "/jail clearforce (Jail name)"
)
public class JailClearForceCommand implements Command {
// If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails
public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(jm.isConfirming(sender.getName())) {
sender.sendMessage(Lang.ALREADY.get());
}else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEARFORCE));
sender.sendMessage(Lang.START.get());
}
return true; //If they made it this far, the command is intact and ready to be processed. :)
}
}