From 68088a33993765837468af17bf5fa8a0717e5c31 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 9 Mar 2024 07:05:48 -0500 Subject: [PATCH] more equip refactored. --- src/engine/objects/CharacterItemManager.java | 24 +++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 6491644c..c1907db8 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -50,7 +50,7 @@ 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<>(); + private final HashSet equipOrder = new HashSet<>(); public Item goldVault; private Account account; private Item goldInventory; @@ -187,7 +187,7 @@ public class CharacterItemManager { case EQUIPPED: if (this.equipped.containsValue(i) == false) { this.equipped.put(i.equipSlot, i); - addEquipOrder(i.equipSlot.ordinal()); + addEquipOrder(i.equipSlot); } break; case BANK: @@ -877,11 +877,10 @@ public class CharacterItemManager { return this.goldVault; } - public void addEquipOrder(int slot) { + public void addEquipOrder(Enum.EquipSlotType slot) { synchronized (this.equipOrder) { - Integer iSlot = slot; - if (this.equipOrder.contains(iSlot)) - this.equipOrder.remove(iSlot); + if (this.equipOrder.contains(slot)) + this.equipOrder.remove(slot); this.equipOrder.add(slot); } } @@ -1314,7 +1313,7 @@ public class CharacterItemManager { i.addToCache(); - addEquipOrder(slot.ordinal()); + addEquipOrder(slot); //calculateWeights(); } @@ -1890,16 +1889,15 @@ public class CharacterItemManager { ArrayList ret = new ArrayList<>(); synchronized (this.equipOrder) { synchronized (this.equipped) { - for (int slot : this.equipOrder) { - Enum.EquipSlotType slotType = Enum.EquipSlotType.values()[slot]; - if (this.equipped.containsKey(slotType)) - ret.add(this.equipped.get(slotType)); + 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.ordinal()))) { - this.equipOrder.add(slot.ordinal()); + if (!(this.equipOrder.contains(slot))) { + this.equipOrder.add(slot); ret.add(this.equipped.get(slot)); } }