Add the confirmation to the clearforce command, continued work on #3.
This commit is contained in:
parent
54bea41d05
commit
82a40c5d8e
@ -263,6 +263,39 @@ public class JailManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forcefully clears all the jails if name provided is null.
|
||||||
|
*
|
||||||
|
* <p />
|
||||||
|
*
|
||||||
|
* This method just clears them from the storage, doesn't release them.
|
||||||
|
*
|
||||||
|
* @param name of the jail to clear, null if all of them.
|
||||||
|
* @return The resulting message to be sent to the caller of this method.
|
||||||
|
*/
|
||||||
|
public String forcefullyClearJailOrJails(String name) {
|
||||||
|
if(name == null) {
|
||||||
|
if(getJails().size() == 0) {
|
||||||
|
return getPlugin().getJailIO().getLanguageString(LangString.NOJAILS);
|
||||||
|
}else {
|
||||||
|
for(Jail j : getJails()) {
|
||||||
|
j.clearPrisoners();
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS));
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
Jail j = getJail(name);
|
||||||
|
|
||||||
|
if(j != null) {
|
||||||
|
j.clearPrisoners();
|
||||||
|
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName());
|
||||||
|
}else {
|
||||||
|
return getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the player is creating a jail or a cell.
|
* Returns whether or not the player is creating a jail or a cell.
|
||||||
*
|
*
|
||||||
|
@ -3,9 +3,10 @@ package com.graywolf336.jail.command.subcommands;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.ConfirmPlayer;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
import com.graywolf336.jail.command.CommandInfo;
|
import com.graywolf336.jail.command.CommandInfo;
|
||||||
|
import com.graywolf336.jail.enums.Confirmation;
|
||||||
import com.graywolf336.jail.enums.LangString;
|
import com.graywolf336.jail.enums.LangString;
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
@ -20,26 +21,11 @@ public class JailClearForceCommand implements Command {
|
|||||||
|
|
||||||
// If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails
|
// 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) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
if(args.length == 2) {
|
if(jm.isConfirming(sender.getName())) {
|
||||||
Jail j = jm.getJail(args[1]);
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
|
||||||
|
|
||||||
if(j != null) {
|
|
||||||
j.clearPrisoners();
|
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName()));
|
|
||||||
}else {
|
}else {
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEARFORCE));
|
||||||
}
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
|
||||||
}else {
|
|
||||||
if(jm.getJails().size() == 0) {
|
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
|
||||||
}else {
|
|
||||||
for(Jail j : jm.getJails()) {
|
|
||||||
j.clearPrisoners();
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED,
|
|
||||||
jm.getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; //If they made it this far, the command is intact and ready to be processed. :)
|
return true; //If they made it this far, the command is intact and ready to be processed. :)
|
||||||
|
@ -35,6 +35,15 @@ public class JailConfirmCommand implements Command{
|
|||||||
//Remove them from confirming so they can't do it again
|
//Remove them from confirming so they can't do it again
|
||||||
jm.removeConfirming(sender.getName());
|
jm.removeConfirming(sender.getName());
|
||||||
break;
|
break;
|
||||||
|
case CLEARFORCE:
|
||||||
|
//Copy the original arguments for easy access
|
||||||
|
String[] cArgs2 = jm.getOriginalArgs(sender.getName());
|
||||||
|
//Forcefully clear a jail if the args length is two, else send null to clear all
|
||||||
|
String msg2 = jm.forcefullyClearJailOrJails(cArgs2.length == 2 ? cArgs2[1] : null);
|
||||||
|
//Send the message we got back
|
||||||
|
sender.sendMessage(msg2);
|
||||||
|
jm.removeConfirming(sender.getName());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHING));
|
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHING));
|
||||||
jm.removeConfirming(sender.getName());
|
jm.removeConfirming(sender.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user