Fix #118, armor being duplicated.
This commit is contained in:
parent
92e6f5e641
commit
9452bcb5a3
@ -275,7 +275,6 @@ public class PrisonerManager {
|
||||
|
||||
//Get the separate inventory, so we can iterate of them
|
||||
ItemStack[] inventory = player.getInventory().getContents();
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
for(ItemStack item : inventory) {
|
||||
if(item != null) {
|
||||
@ -288,18 +287,6 @@ public class PrisonerManager {
|
||||
}
|
||||
}
|
||||
|
||||
for(ItemStack item : armor) {
|
||||
if(item != null) {
|
||||
if(!Util.isStringInsideList(item.getType().toString(), blacklist)) {
|
||||
int i = chest.firstEmpty();
|
||||
if(i != -1) {//Check that we have got a free spot, should never happen but just in case
|
||||
chest.setItem(i, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
}else {
|
||||
for(ItemStack item : player.getInventory().getContents())
|
||||
@ -312,9 +299,7 @@ public class PrisonerManager {
|
||||
if(Util.isStringInsideList(item.getType().toString(), blacklist))
|
||||
player.getInventory().remove(item);
|
||||
|
||||
String[] inv = Util.playerInventoryToBase64(player.getInventory());
|
||||
prisoner.setInventory(inv[0]);
|
||||
prisoner.setArmor(inv[1]);
|
||||
prisoner.setInventory(Util.toBase64(player.getInventory()));
|
||||
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
@ -344,9 +329,7 @@ public class PrisonerManager {
|
||||
if(Util.isStringInsideList(item.getType().toString(), blacklist))
|
||||
player.getInventory().remove(item);
|
||||
|
||||
String[] inv = Util.playerInventoryToBase64(player.getInventory());
|
||||
prisoner.setInventory(inv[0]);
|
||||
prisoner.setArmor(inv[1]);
|
||||
prisoner.setInventory(Util.toBase64(player.getInventory()));
|
||||
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
|
@ -17,7 +17,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
@ -345,21 +344,6 @@ public class Util {
|
||||
return unused;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the player inventory to a String array of Base64 strings. First string is the content and second string is the armor.
|
||||
*
|
||||
* @param playerInventory to turn into an array of strings.
|
||||
* @return Array of strings: [ main content, armor content ]
|
||||
* @throws IllegalStateException if any of the {@link ItemStack}s couldn't be parsed
|
||||
*/
|
||||
public static String[] playerInventoryToBase64(PlayerInventory playerInventory) throws IllegalStateException {
|
||||
//get the main content part, this doesn't return the armor
|
||||
String content = toBase64(playerInventory);
|
||||
String armor = itemStackArrayToBase64(playerInventory.getArmorContents());
|
||||
|
||||
return new String[] { content, armor };
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* A method to serialize an {@link ItemStack} array to Base64 String.
|
||||
|
Loading…
Reference in New Issue
Block a user