Finish up the confirmations for #3.

This commit is contained in:
graywolf336
2014-02-14 21:37:39 -06:00
parent 82a40c5d8e
commit 52456edc6b
5 changed files with 145 additions and 62 deletions

View File

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