From 05b15cc9b85ea2288d5e1d9b86e5eed4405900ab Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Sat, 28 Dec 2013 15:39:14 -0600 Subject: [PATCH] Let's try to remove people from the storage system this way. --- .../java/com/graywolf336/jail/JailIO.java | 31 +++++++++++++++++++ .../com/graywolf336/jail/PrisonerManager.java | 5 +-- 2 files changed, 34 insertions(+), 2 deletions(-) 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) {