Only try to jail in a cell if that jail has cells, resolves #51

This commit is contained in:
graywolf336 2015-02-16 15:00:14 -06:00
parent 7e2df93add
commit 0d9ed022f3
2 changed files with 13 additions and 1 deletions

View File

@ -154,6 +154,11 @@ public class Jail {
this.nocellPrisoners.remove(p.getUUID()); this.nocellPrisoners.remove(p.getUUID());
} }
/** Returns if there are any cells or not. */
public boolean hasCells() {
return !this.cells.isEmpty();
}
/** Adds a cell to the Jail. */ /** Adds a cell to the Jail. */
public void addCell(Cell cell, boolean save) { public void addCell(Cell cell, boolean save) {
if(save) plugin.getJailIO().saveCell(this, cell); if(save) plugin.getJailIO().saveCell(this, cell);

View File

@ -152,7 +152,14 @@ public class JailCommand implements Command {
//If they want just any open cell or automatic jailing in cells is turned on //If they want just any open cell or automatic jailing in cells is turned on
//and a cell wasn't already found, then find try to find a cell //and a cell wasn't already found, then find try to find a cell
if((params.isAnyCell() || jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICCELL.getPath(), true)) && c == null) { if(params.isAnyCell() && c == null) {
c = jm.getJail(jailName).getFirstEmptyCell();
if(c == null) {
//If there wasn't an empty cell, then tell them so.
sender.sendMessage(Lang.NOEMPTYCELLS.get(jailName));
return true;
}
}else if(jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICCELL.getPath(), true) && j.hasCells() && c == null) {
c = jm.getJail(jailName).getFirstEmptyCell(); c = jm.getJail(jailName).getFirstEmptyCell();
if(c == null) { if(c == null) {
//If there wasn't an empty cell, then tell them so. //If there wasn't an empty cell, then tell them so.