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.
This commit is contained in:
graywolf336 2013-12-27 13:16:21 -06:00
parent 5e4bc77579
commit 07f3d85a2a
2 changed files with 12 additions and 0 deletions

View File

@ -42,6 +42,7 @@ public class Cell {
return this.p;
}
/** Nullifies the prisoner data. */
public void removePrisoner() {
this.p = null;
}

View File

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