diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index 96cbd69..0952f74 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -352,4 +352,35 @@ public class JailIO { break; } } + + /** + * Removes the prisoner from the storage system. + * + * @param j the jail which the prisoner is in. + * @param p the prisoner data + */ + public void removePrisoner(Jail j, Prisoner p) { + this.removePrisoner(j, null, p); + } + + /** + * Removes the prisoner from the storage system. + * + * @param j the jail which the prisoner is in. + * @param c the cell which the prisoner is in, null if none + * @param p the prisoner data + */ + public void removePrisoner(Jail j, Cell c, Prisoner p) { + switch(storage) { + case 1: + case 2: + break; + default: + if(c == null) + flat.set("jails." + j.getName() + ".prisoners." + p.getName(), null); + else + flat.set("jails." + j.getName() + "." + c.getName() + ".prisoner", null); + break; + } + } } diff --git a/src/main/java/com/graywolf336/jail/PrisonerManager.java b/src/main/java/com/graywolf336/jail/PrisonerManager.java index f774629..59ee68e 100644 --- a/src/main/java/com/graywolf336/jail/PrisonerManager.java +++ b/src/main/java/com/graywolf336/jail/PrisonerManager.java @@ -336,13 +336,14 @@ public class PrisonerManager { restoreInventory(player, prisoner); } + pl.getJailIO().removePrisoner(jail, cell, prisoner); cell.removePrisoner(); }else { restoreInventory(player, prisoner); + + pl.getJailIO().removePrisoner(jail, prisoner); jail.removePrisoner(prisoner); } - - pl.getJailIO().saveJail(jail); } private void restoreInventory(Player player, Prisoner prisoner) {