diff --git a/src/main/java/com/graywolf336/jail/beans/Jail.java b/src/main/java/com/graywolf336/jail/beans/Jail.java index 10e0607..4937c90 100644 --- a/src/main/java/com/graywolf336/jail/beans/Jail.java +++ b/src/main/java/com/graywolf336/jail/beans/Jail.java @@ -153,6 +153,11 @@ public class Jail { public void removePrisoner(Prisoner p) { 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. */ public void addCell(Cell cell, boolean save) { diff --git a/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java index 3bc2b9d..a8d8e52 100644 --- a/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailCommand.java @@ -152,7 +152,14 @@ public class JailCommand implements Command { //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 - 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(); if(c == null) { //If there wasn't an empty cell, then tell them so.