forked from MagicBane/Server
more equip refactored.
This commit is contained in:
@@ -50,7 +50,7 @@ public class CharacterItemManager {
|
||||
private final HashSet<Item> inventory = new HashSet<>();
|
||||
private final HashSet<Item> bank = new HashSet<>();
|
||||
private final HashSet<Item> vault = new HashSet<>();
|
||||
private final HashSet<Integer> equipOrder = new HashSet<>();
|
||||
private final HashSet<Enum.EquipSlotType> 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<Item> 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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user