Logic cleanup

This commit is contained in:
2024-03-09 09:30:58 -05:00
parent c6f451bce1
commit f6fbc6fecb
2 changed files with 27 additions and 22 deletions
+17 -12
View File
@@ -984,41 +984,46 @@ public class CharacterItemManager {
return true;
}
public synchronized boolean moveItemToInventory(Item i) {
public synchronized boolean moveItemToInventory(Item item) {
boolean fromEquip = false;
synchronized (this) {
//Skip if NOT in vault.
if (i.containerType != Enum.ItemContainerType.VAULT)
if (this.doesCharOwnThisItem(i.getObjectUUID()) == false)
if (item.containerType != Enum.ItemContainerType.VAULT)
if (this.doesCharOwnThisItem(item.getObjectUUID()) == false)
return false;
// Only valid from bank, equip and vault
if (!bankContains(i) && !equippedContains(i) && !vaultContains(i))
if (!bankContains(item) && !equippedContains(item) && !vaultContains(item))
return false;
if (equippedContains(i)) {
if (equippedContains(item)) {
fromEquip = true;
ItemBase ib = i.getItemBase();
ItemBase ib = item.getItemBase();
if (ib != null && ib.getType().equals(ItemType.GOLD))
this.absCharacter.cancelOnUnEquip();
}
// Clear equipment of item.
this.absCharacter.charItemManager.equipped.remove(item.equipSlot);
// check to see what type of AbstractCharacter subclass we have stored
if (this.absCharacter.getClass() == PlayerCharacter.class) {
if (!i.moveItemToInventory((PlayerCharacter) this.absCharacter))
if (!item.moveItemToInventory((PlayerCharacter) this.absCharacter))
return false;
} else if (!i.moveItemToInventory((NPC) this.absCharacter))
} else if (!item.moveItemToInventory((NPC) this.absCharacter))
return false;
// remove it from other lists:
this.remItemFromLists(i);
this.remItemFromLists(item);
// add to Inventory
this.inventory.add(i);
i.addToCache();
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
this.inventory.add(item);
item.addToCache();
this.itemIDtoType.put(item.getObjectUUID(), item.getObjectType().ordinal());
calculateWeights();
}