diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index a0c2ab30..0e2c6ec4 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -47,7 +47,6 @@ public class CharacterItemManager { private final HashSet inventory = new HashSet<>(); private final HashSet bank = new HashSet<>(); private final HashSet vault = new HashSet<>(); - private final HashSet equipOrder = new HashSet<>(); public Item goldVault; private Account account; private Item goldInventory; @@ -182,10 +181,8 @@ public class CharacterItemManager { switch (i.containerType) { case EQUIPPED: - if (this.equipped.containsValue(i) == false) { + if (this.equipped.containsValue(i) == false) this.equipped.put(i.equipSlot, i); - addEquipOrder(i.equipSlot); - } break; case BANK: if (i.template.item_type.equals(ItemType.GOLD)) @@ -875,14 +872,6 @@ public class CharacterItemManager { return this.goldVault; } - public void addEquipOrder(Enum.EquipSlotType slot) { - synchronized (this.equipOrder) { - if (this.equipOrder.contains(slot)) - this.equipOrder.remove(slot); - this.equipOrder.add(slot); - } - } - public synchronized boolean doesCharOwnThisItem(int itemID) { return this.itemIDtoType.containsKey(itemID); } @@ -1311,8 +1300,6 @@ public class CharacterItemManager { i.addToCache(); - addEquipOrder(slot); - //calculateWeights(); } @@ -1622,7 +1609,7 @@ public class CharacterItemManager { // make sure current player has item in inventory if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob))) return null; - else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD)) + else if (!this.inventory.contains(lootItem) && !this.equipped.containsValue(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD)) return null; // get weight of item @@ -1882,27 +1869,6 @@ public class CharacterItemManager { } } - public ArrayList getEquippedList() { - ArrayList ret = new ArrayList<>(); - synchronized (this.equipOrder) { - synchronized (this.equipped) { - for (Enum.EquipSlotType slot : this.equipOrder) { - if (this.equipped.containsKey(slot)) - ret.add(this.equipped.get(slot)); - } - if (ret.size() != this.equipped.size()) - //missed adding some items, figure out what. - for (Enum.EquipSlotType slot : this.equipped.keySet()) { - if (!(this.equipOrder.contains(slot))) { - this.equipOrder.add(slot); - ret.add(this.equipped.get(slot)); - } - } - } - } - return ret; - } - public Item getEquipped(Enum.EquipSlotType slot) { synchronized (this.equipped) { return this.equipped.get(slot); @@ -2547,33 +2513,8 @@ public class CharacterItemManager { public synchronized void clearEquip() { - ArrayList equipCopy = new ArrayList<>(this.getEquippedList()); - Iterator ii = equipCopy.iterator(); - while (ii.hasNext()) { - Item itm = ii.next(); - this.getEquippedList().remove(itm); - this.delete(itm); - } - } - - public byte getEquipVer() { - return this.equipVer; - } - - public void incEquipVer() { - this.equipVer++; - } - - public void incInventoryVer() { - this.equipVer++; - } - - public void incBankVer() { - this.equipVer++; - } + this.equipped.clear(); - public void incVaultVer() { - this.equipVer++; } public int getTradeID() { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 5aca39d3..8104928e 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -448,11 +448,8 @@ public class PlayerCharacter extends AbstractCharacter { } else writer.putInt(0); - - ArrayList equipped = playerCharacter.charItemManager.getEquippedList(); - - writer.putInt(equipped.size()); - for (Item item : equipped) { + writer.putInt(playerCharacter.charItemManager.equipped.size()); + for (Item item : playerCharacter.charItemManager.equipped.values()) { Item._serializeForClientMsg(item, writer); } writer.putInt(playerCharacter.getRank());