Finish up the confirmations for #3.
This commit is contained in:
@ -44,6 +44,36 @@ public class JailConfirmCommand implements Command{
|
||||
sender.sendMessage(msg2);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETECELL:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs3 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String msg3 = jm.deleteJailCell(cArgs3[1], cArgs3[2]);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg3);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETECELLS:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs4 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String[] msgs4 = jm.deleteAllJailCells(cArgs4[1]);
|
||||
//Send the messages we got back
|
||||
for(String s : msgs4) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETE:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs5 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String msg5 = jm.deleteJail(cArgs5[1]);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg5);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHING));
|
||||
jm.removeConfirming(sender.getName());
|
||||
|
@ -3,9 +3,10 @@ package com.graywolf336.jail.command.subcommands;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
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.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
@ -18,27 +19,11 @@ import com.graywolf336.jail.enums.LangString;
|
||||
)
|
||||
public class JailDeleteCellCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
//Check if the jail name provided is a valid jail
|
||||
if(jm.isValidJail(args[1])) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
//check if the cell is a valid cell
|
||||
if(j.isValidCell(args[2])) {
|
||||
if(j.getCell(args[2]).hasPrisoner()) {
|
||||
//The cell has a prisoner, so tell them to first transfer the prisoner
|
||||
//or release the prisoner
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVALUNSUCCESSFUL, new String[] { args[2], args[1] }));
|
||||
}else {
|
||||
j.removeCell(args[2]);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED, new String[] { args[2], args[1] }));
|
||||
}
|
||||
}else {
|
||||
//No cell found by the provided name in the stated jail
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL, new String[] { args[2], args[1] }));
|
||||
}
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
|
||||
}else {
|
||||
//No jail found by the provided name
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELL));
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,14 +1,12 @@
|
||||
package com.graywolf336.jail.command.subcommands;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
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.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
@ -21,31 +19,11 @@ import com.graywolf336.jail.enums.LangString;
|
||||
)
|
||||
public class JailDeleteCellsCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
//Check if the jail name provided is a valid jail
|
||||
if(jm.isValidJail(args[1])) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
if(j.getCellCount() == 0) {
|
||||
//There are no cells in this jail, thus we can't delete them.
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, args[1]));
|
||||
}else {
|
||||
//Keep a local copy of the hashset so that we don't get any CMEs.
|
||||
HashSet<Cell> cells = new HashSet<Cell>(j.getCells());
|
||||
|
||||
for(Cell c : cells) {
|
||||
if(c.hasPrisoner()) {
|
||||
//The cell has a prisoner, so tell them to first transfer the prisoner
|
||||
//or release the prisoner
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVALUNSUCCESSFUL, new String[] { c.getName(), args[1] }));
|
||||
}else {
|
||||
j.removeCell(c.getName());
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED, new String[] { args[2], args[1] }));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
|
||||
}else {
|
||||
//No jail found by the provided name
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELLS));
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3,8 +3,10 @@ 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.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
@ -17,20 +19,11 @@ import com.graywolf336.jail.enums.LangString;
|
||||
)
|
||||
public class JailDeleteCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
//Check if the jail name provided is a valid jail
|
||||
if(jm.isValidJail(args[1])) {
|
||||
//check if the jail doesn't contain prisoners
|
||||
if(jm.getJail(args[1]).getAllPrisoners().size() == 0) {
|
||||
//There are no prisoners, so we can delete it
|
||||
jm.removeJail(args[1]);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILREMOVED, args[1]));
|
||||
}else {
|
||||
//The jail has prisoners, they need to release them first
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILREMOVALUNSUCCESSFUL, args[1]));
|
||||
}
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
|
||||
}else {
|
||||
//No jail found by the provided name
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETE));
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user