From 07f3d85a2aa1bd418a71f1b7b01fbd686bfa6e96 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Fri, 27 Dec 2013 13:16:21 -0600 Subject: [PATCH] Don't allow prisoners to be jailed into the same cell as someone else. This will prevent overriding inventories in cell chests. When we tell them the destination cell already has a prisoner in it, we try to find the first empty cell in that jail but if all the jail's cells are full then we tell them that as well. --- src/main/java/com/graywolf336/jail/beans/Cell.java | 1 + .../jail/command/commands/JailCommand.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/graywolf336/jail/beans/Cell.java b/src/main/java/com/graywolf336/jail/beans/Cell.java index 11bd985..65882a3 100644 --- a/src/main/java/com/graywolf336/jail/beans/Cell.java +++ b/src/main/java/com/graywolf336/jail/beans/Cell.java @@ -42,6 +42,7 @@ public class Cell { return this.p; } + /** Nullifies the prisoner data. */ public void removePrisoner() { this.p = null; } diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java b/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java index b31de48..f9a545f 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java +++ b/src/main/java/com/graywolf336/jail/command/commands/JailCommand.java @@ -94,6 +94,17 @@ public class JailCommand implements Command { if(!params.cell().isEmpty()) { if(jm.getJail(params.jail()).getCell(params.cell()) == null) { sender.sendMessage(ChatColor.RED + "The cell provided does not exist."); + return true; + }else if(jm.getJail(params.jail()).getCell(params.cell()).hasPrisoner()) { + //If the cell has a prisoner, don't allow jailing them to that particular cell + sender.sendMessage(ChatColor.RED + "The destination cell already has a prisoner in it."); + Cell suggestedCell = jm.getJail(params.jail()).getFirstEmptyCell(); + if(suggestedCell != null) { + sender.sendMessage(ChatColor.RED + "We found an empty cell in the same jail (" + params.jail() + ") with the name: " + suggestedCell.getName()); + }else { + sender.sendMessage(ChatColor.RED + "We didn't find any empty cells, this jail's (" + params.jail() + ") cells appear to be full"); + } + return true; } }