From 658b442b3644c01a1168743d12622a675d9a15e6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 9 Mar 2024 09:55:00 -0500 Subject: [PATCH] Logic cleanup --- ...TransferItemFromEquipToInventoryHandler.java | 4 +--- src/engine/objects/CharacterItemManager.java | 17 +++++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java b/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java index 3be438a1..70f04fc6 100644 --- a/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java +++ b/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java @@ -58,10 +58,8 @@ public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHa if (!item.validForEquip(origin, player, itemManager)) return true; - if (item.containerType == Enum.ItemContainerType.EQUIPPED) { - itemManager.equipped.remove(item.equipSlot); + if (item.containerType == Enum.ItemContainerType.EQUIPPED) itemManager.moveItemToInventory(item); - } int ItemType = item.getObjectType().ordinal(); int ItemID = item.getObjectUUID(); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 215b8eac..421f6661 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1005,9 +1005,8 @@ public class CharacterItemManager { this.absCharacter.cancelOnUnEquip(); } - // Clear equipment of item. - - this.absCharacter.charItemManager.equipped.remove(item.equipSlot); + // remove it from other lists: + this.remItemFromLists(item); // check to see what type of AbstractCharacter subclass we have stored @@ -1017,9 +1016,6 @@ public class CharacterItemManager { } else if (!item.moveItemToInventory((NPC) this.absCharacter)) return false; - // remove it from other lists: - this.remItemFromLists(item); - // add to Inventory this.inventory.add(item); item.addToCache(); @@ -1695,10 +1691,11 @@ public class CharacterItemManager { return lootItem; } - private synchronized void remItemFromLists(Item i) { - this.vault.remove(i); - this.bank.remove(i); - this.inventory.remove(i); + private synchronized void remItemFromLists(Item item) { + this.equipped.remove(item.equipSlot); + this.vault.remove(item); + this.bank.remove(item); + this.inventory.remove(item); } /*