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:
parent
5e4bc77579
commit
07f3d85a2a
@ -42,6 +42,7 @@ public class Cell {
|
|||||||
return this.p;
|
return this.p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Nullifies the prisoner data. */
|
||||||
public void removePrisoner() {
|
public void removePrisoner() {
|
||||||
this.p = null;
|
this.p = null;
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,17 @@ public class JailCommand implements Command {
|
|||||||
if(!params.cell().isEmpty()) {
|
if(!params.cell().isEmpty()) {
|
||||||
if(jm.getJail(params.jail()).getCell(params.cell()) == null) {
|
if(jm.getJail(params.jail()).getCell(params.cell()) == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "The cell provided does not exist.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user