From 1cf9831e2008bf435d3363dca5250685e25c188c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 28 Mar 2024 05:34:50 -0400 Subject: [PATCH] Itembase refactored out of gold --- src/engine/objects/Account.java | 2 +- src/engine/objects/CharacterItemManager.java | 4 +-- src/engine/objects/Item.java | 31 +++++--------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/engine/objects/Account.java b/src/engine/objects/Account.java index 07cd442d..5e8f4a85 100644 --- a/src/engine/objects/Account.java +++ b/src/engine/objects/Account.java @@ -182,7 +182,7 @@ public class Account extends AbstractGameObject { } if (this.vaultGold == null) { - this.vaultGold = Item.newGoldItem(this.getObjectUUID(), ItemBase.getItemBase(7), ItemContainerType.VAULT); + this.vaultGold = Item.newGoldItem(this.getObjectUUID(), ItemContainerType.VAULT); if (this.vaultGold != null) this.vault.add(this.vaultGold); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index aa9690b9..7f585166 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -87,14 +87,14 @@ public class CharacterItemManager { //create inventory gold if needed if (this.goldInventory == null) if (this.absCharacter != null && (this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter) || this.absCharacter.getObjectType().equals(GameObjectType.NPC))) - this.goldInventory = Item.newGoldItem(this.absCharacter, ItemBase.getItemBase(7), Enum.ItemContainerType.INVENTORY); + this.goldInventory = Item.newGoldItem(this.absCharacter, Enum.ItemContainerType.INVENTORY); else this.goldInventory = new MobLoot(this.absCharacter, 0); //create bank gold if needed if (this.goldBank == null) if (this.absCharacter != null && this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)) - this.goldBank = Item.newGoldItem(this.absCharacter, ItemBase.getItemBase(7), Enum.ItemContainerType.BANK); + this.goldBank = Item.newGoldItem(this.absCharacter, Enum.ItemContainerType.BANK); else this.goldBank = new MobLoot(this.absCharacter, 0); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 0ef101d7..f035e86e 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -539,16 +539,16 @@ public class Item extends AbstractWorldObject { return (Item) DbManager.getFromCache(GameObjectType.Item, id); } - public static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType) { - return newGoldItem(awo, ib, containerType, true); + public static Item newGoldItem(AbstractWorldObject awo, Enum.ItemContainerType containerType) { + return newGoldItem(awo, containerType, true); } //used for vault! - public static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType) { - return newGoldItem(accountID, ib, containerType, true); + public static Item newGoldItem(int accountID, Enum.ItemContainerType containerType) { + return newGoldItem(accountID, containerType, true); } - private static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) { + private static Item newGoldItem(int accountID, Enum.ItemContainerType containerType, boolean persist) { int ownerID; OwnerType ownerType; @@ -556,7 +556,7 @@ public class Item extends AbstractWorldObject { ownerID = accountID; ownerType = OwnerType.Account; - Item newGold = new Item(ib.getUUID()); + Item newGold = new Item(ResourceType.GOLD.templateID); newGold.ownerID = ownerID; newGold.ownerType = ownerType; newGold.containerType = containerType; @@ -574,7 +574,7 @@ public class Item extends AbstractWorldObject { return newGold; } - private static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) { + private static Item newGoldItem(AbstractWorldObject awo, Enum.ItemContainerType containerType, boolean persist) { int ownerID; OwnerType ownerType; @@ -610,7 +610,7 @@ public class Item extends AbstractWorldObject { } } - Item newGold = new Item(ib.getUUID()); + Item newGold = new Item(ResourceType.GOLD.templateID); newGold.ownerID = ownerID; newGold.ownerType = ownerType; newGold.containerType = containerType; @@ -628,21 +628,6 @@ public class Item extends AbstractWorldObject { return newGold; } - // This is to be used for trades - the new item is not stored in the database - public static Item newGoldItemTemp(AbstractWorldObject awo, ItemBase ib) { - return Item.newGoldItem(awo, ib, Enum.ItemContainerType.NONE, false); - } - - public static Item getItem(int UUID) { - if (UUID == 0) - return null; - - Item item = (Item) DbManager.getFromCache(GameObjectType.Item, UUID); - if (item != null) - return item; - return DbManager.ItemQueries.GET_ITEM(UUID); - } - public static void addEnchantValue(String enchant, int value) { Item.enchantValues.put(enchant, value); }