Clear inventory only when storing, fixes #57
We shouldn't be clearing a prisoner's inventory on getting released from jail if we aren't supposed to be storing it. And update the readme file
This commit is contained in:
parent
ab10bc9a4d
commit
25835a1702
@ -14,6 +14,14 @@ Beta 5 Changes
|
||||
===
|
||||
*Changes since Beta 4*
|
||||
* Added the ability to show `reason`, `jail`, and `cell` to the broadcast messages. [#53](https://github.com/graywolf336/Jail/issues/53)
|
||||
* Changed how we handle inventory when storing is set to false. Don't remove their inventory when they are unjailed and we don't store it. [#57](https://github.com/graywolf336/Jail/issues/57)
|
||||
* Changed the jail api, see [#72's comment](https://github.com/graywolf336/Jail/issues/72#issuecomment-104757472) for some details
|
||||
* Changed the format of the jail check command, thanks to stevoh6. [#65](https://github.com/graywolf336/Jail/pull/65)
|
||||
* Changed the explanation of why the gamemode setting was problematic and give the available options. [#73](https://github.com/graywolf336/Jail/issues/73)
|
||||
* Fixed an issue where cell data was being duplicated (or more) in the database [#74](https://github.com/graywolf336/Jail/issues/74)
|
||||
* Fixed jail sticks not putting players into cells. [#68](https://github.com/graywolf336/Jail/issues/68)
|
||||
* Fixed respawning after dying not placing players back into their cells when another plugin sets their respawn point. [#55](https://github.com/graywolf336/Jail/issues/55)
|
||||
* Fixed time being added/subtracted from a player's time when they were jailed forever, resulting in them being able to get out. [#69](https://github.com/graywolf336/Jail/issues/69)
|
||||
|
||||
[Beta 4](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.4) Changes
|
||||
===
|
||||
|
@ -465,45 +465,52 @@ public class PrisonerManager {
|
||||
player.setGameMode(prisoner.getPreviousGameMode());
|
||||
}
|
||||
|
||||
//Now, let's restore their inventory
|
||||
//First up, clear their inventory
|
||||
player.closeInventory();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
//Now, let's restore their inventory if we can store it but
|
||||
//first up is clearing their inventory...if we can store it
|
||||
boolean store = pl.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath(), true);
|
||||
if(store) {
|
||||
player.closeInventory();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
}
|
||||
|
||||
//if the cell isn't null, let's check if the cell has a chest and if so then try out best to restore
|
||||
//the prisoner's inventory from that
|
||||
if(cell != null) {
|
||||
if(cell.hasChest()) {
|
||||
Inventory chest = cell.getChest().getInventory();
|
||||
if(store) {
|
||||
if(cell.hasChest()) {
|
||||
Inventory chest = cell.getChest().getInventory();
|
||||
|
||||
for (ItemStack item : chest.getContents()) {
|
||||
if (item == null || item.getType() == Material.AIR) continue;
|
||||
for (ItemStack item : chest.getContents()) {
|
||||
if (item == null || item.getType() == Material.AIR) continue;
|
||||
|
||||
if(item.getType().toString().toLowerCase().contains("helmet") && (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR)) {
|
||||
player.getInventory().setHelmet(item);
|
||||
} else if(item.getType().toString().toLowerCase().contains("chestplate") && (player.getInventory().getChestplate() == null || player.getInventory().getChestplate().getType() == Material.AIR)) {
|
||||
player.getInventory().setChestplate(item);
|
||||
} else if(item.getType().toString().toLowerCase().contains("leg") && (player.getInventory().getLeggings() == null || player.getInventory().getLeggings().getType() == Material.AIR)) {
|
||||
player.getInventory().setLeggings(item);
|
||||
} else if(item.getType().toString().toLowerCase().contains("boots") && (player.getInventory().getBoots() == null || player.getInventory().getBoots().getType() == Material.AIR)) {
|
||||
player.getInventory().setBoots(item);
|
||||
} else if (player.getInventory().firstEmpty() == -1) {
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
} else {
|
||||
player.getInventory().addItem(item);
|
||||
if(item.getType().toString().toLowerCase().contains("helmet") && (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR)) {
|
||||
player.getInventory().setHelmet(item);
|
||||
} else if(item.getType().toString().toLowerCase().contains("chestplate") && (player.getInventory().getChestplate() == null || player.getInventory().getChestplate().getType() == Material.AIR)) {
|
||||
player.getInventory().setChestplate(item);
|
||||
} else if(item.getType().toString().toLowerCase().contains("leg") && (player.getInventory().getLeggings() == null || player.getInventory().getLeggings().getType() == Material.AIR)) {
|
||||
player.getInventory().setLeggings(item);
|
||||
} else if(item.getType().toString().toLowerCase().contains("boots") && (player.getInventory().getBoots() == null || player.getInventory().getBoots().getType() == Material.AIR)) {
|
||||
player.getInventory().setBoots(item);
|
||||
} else if (player.getInventory().firstEmpty() == -1) {
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
} else {
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chest.clear();
|
||||
chest.clear();
|
||||
}else {
|
||||
Util.restoreInventory(player, prisoner);
|
||||
}
|
||||
}else {
|
||||
Util.restoreInventory(player, prisoner);
|
||||
if(cell.hasChest()) cell.getChest().getInventory().clear();
|
||||
}
|
||||
|
||||
pl.getJailIO().removePrisoner(jail, cell == null ? null : (Cell)cell, prisoner);
|
||||
pl.getJailIO().removePrisoner(jail, (Cell)cell, prisoner);
|
||||
cell.removePrisoner();
|
||||
}else {
|
||||
Util.restoreInventory(player, prisoner);
|
||||
if(store) Util.restoreInventory(player, prisoner);
|
||||
|
||||
pl.getJailIO().removePrisoner(jail, prisoner);
|
||||
jail.removePrisoner(prisoner);
|
||||
|
Loading…
Reference in New Issue
Block a user