From 6ed4faded2fbb34edb8859e43236f5285f1807a6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 15 Mar 2024 10:35:41 -0400 Subject: [PATCH] Refactor out itembase --- src/engine/db/handlers/dbItemHandler.java | 2 +- src/engine/devcmd/cmds/InfoCmd.java | 2 +- src/engine/devcmd/cmds/PrintBankCmd.java | 2 +- src/engine/devcmd/cmds/PrintBonusesCmd.java | 2 +- src/engine/devcmd/cmds/PrintEquipCmd.java | 2 +- src/engine/devcmd/cmds/PrintInventoryCmd.java | 2 +- src/engine/devcmd/cmds/PrintVaultCmd.java | 2 +- src/engine/gameManager/ChatManager.java | 2 +- src/engine/gameManager/LootManager.java | 6 +++--- .../handlers/ActivateNPCMsgHandler.java | 2 +- .../handlers/ObjectActionMsgHandler.java | 2 +- .../net/client/msg/ItemProductionMsg.java | 4 ++-- src/engine/net/client/msg/ManageNPCMsg.java | 4 ++-- src/engine/objects/Item.java | 20 +++++++++---------- src/engine/objects/ItemFactory.java | 20 +++++++++---------- src/engine/objects/Warehouse.java | 6 +++--- 16 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 42c36f49..d1ec7801 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -61,7 +61,7 @@ public class dbItemHandler extends dbHandlerBase { PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) { preparedStatement.setInt(1, toAdd.ownerID); - preparedStatement.setInt(2, toAdd.getTemplsteID()); + preparedStatement.setInt(2, toAdd.getTemplateID()); preparedStatement.setInt(3, (byte) toAdd.chargesRemaining); preparedStatement.setInt(4, (short) toAdd.durabilityCurrent); preparedStatement.setInt(5, (int) toAdd.template.item_health_full); diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 0416a820..fd6393b4 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -506,7 +506,7 @@ public class InfoCmd extends AbstractDevCmd { case MobLoot: Item item = (Item) target; ItemBase itemBase = item.getItemBase(); - ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID()); output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20); output += "Weight: " + template.item_wt; output += newline; diff --git a/src/engine/devcmd/cmds/PrintBankCmd.java b/src/engine/devcmd/cmds/PrintBankCmd.java index 9ca407af..a1d811f3 100644 --- a/src/engine/devcmd/cmds/PrintBankCmd.java +++ b/src/engine/devcmd/cmds/PrintBankCmd.java @@ -52,7 +52,7 @@ public class PrintBankCmd extends AbstractDevCmd { throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); for (Item item : list) { - ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID()); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems()); } diff --git a/src/engine/devcmd/cmds/PrintBonusesCmd.java b/src/engine/devcmd/cmds/PrintBonusesCmd.java index cc7300f8..2f450e93 100644 --- a/src/engine/devcmd/cmds/PrintBonusesCmd.java +++ b/src/engine/devcmd/cmds/PrintBonusesCmd.java @@ -33,7 +33,7 @@ public class PrintBonusesCmd extends AbstractDevCmd { if (target instanceof Item) { type = "Item"; tar = (Item) target; - ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplateID()); name = template.item_base_name; } else if (target instanceof AbstractCharacter) { tar = (AbstractCharacter) target; diff --git a/src/engine/devcmd/cmds/PrintEquipCmd.java b/src/engine/devcmd/cmds/PrintEquipCmd.java index 9037d51a..ab87e3eb 100644 --- a/src/engine/devcmd/cmds/PrintEquipCmd.java +++ b/src/engine/devcmd/cmds/PrintEquipCmd.java @@ -89,7 +89,7 @@ public class PrintEquipCmd extends AbstractDevCmd { for (Enum.EquipSlotType slot : list.keySet()) { Item item = list.get(slot); - ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID()); throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot); } } diff --git a/src/engine/devcmd/cmds/PrintInventoryCmd.java b/src/engine/devcmd/cmds/PrintInventoryCmd.java index 28d58568..90e31943 100644 --- a/src/engine/devcmd/cmds/PrintInventoryCmd.java +++ b/src/engine/devcmd/cmds/PrintInventoryCmd.java @@ -75,7 +75,7 @@ public class PrintInventoryCmd extends AbstractDevCmd { int goldCount = 0; for (Item item : inventory) { - ItemTemplate template = ItemTemplate.itemTemplates.get(item.templsteID); + ItemTemplate template = ItemTemplate.itemTemplates.get(item.templateID); if (item.template.item_type.equals(ItemType.GOLD) == false) { diff --git a/src/engine/devcmd/cmds/PrintVaultCmd.java b/src/engine/devcmd/cmds/PrintVaultCmd.java index 1bf283a5..0e77732d 100644 --- a/src/engine/devcmd/cmds/PrintVaultCmd.java +++ b/src/engine/devcmd/cmds/PrintVaultCmd.java @@ -50,7 +50,7 @@ public class PrintVaultCmd extends AbstractDevCmd { ArrayList list = cim.getVault(); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); for (Item item : list) { - ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID()); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems()); } Item gold = cim.getGoldVault(); diff --git a/src/engine/gameManager/ChatManager.java b/src/engine/gameManager/ChatManager.java index ffd5bcef..e23a71c5 100644 --- a/src/engine/gameManager/ChatManager.java +++ b/src/engine/gameManager/ChatManager.java @@ -612,7 +612,7 @@ public enum ChatManager { name = amount + " gold "; else { String vowels = "aeiou"; - ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID()); String iName = template.item_base_name; if (iName.length() > 0) if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 5b3522e0..1ce69704 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -87,7 +87,7 @@ public enum LootManager { if (ib == null) break; - ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplateID()); if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) { ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?"); @@ -381,8 +381,8 @@ public enum LootManager { int tableID = 0; - if (_bootySetMap.get(gift.getTemplsteID()) != null) - tableID = _bootySetMap.get(gift.getTemplsteID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplsteID()).size())).genTable; + if (_bootySetMap.get(gift.getTemplateID()) != null) + tableID = _bootySetMap.get(gift.getTemplateID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplateID()).size())).genTable; if (tableID == 0) return; diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index a7ea75c6..b0fd0222 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -50,7 +50,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { for (Item hirelings : player.getInventory()) { if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) { - contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templsteID); + contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID); if (contract == null) continue; diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 33d4d4bc..a7e4cd44 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -77,7 +77,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) { - int uuid = item.templsteID; + int uuid = item.templateID; switch (item.template.item_type) { diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index cd14e6e1..bb67ee30 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -284,7 +284,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(this.itemUUID); writer.putInt(0); //items left to produce? if (toRoll != null) { - writer.putInt(toRoll.getTemplsteID()); + writer.putInt(toRoll.getTemplateID()); writer.putInt(toRoll.getValue()); } else { writer.putInt(0); @@ -301,7 +301,7 @@ public class ItemProductionMsg extends ClientNetMsg { timeLeft /= 1000; writer.putInt((int) timeLeft); - writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplsteID())); + writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplateID())); } } else { diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 475ec16a..30887bb3 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -450,14 +450,14 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(i.getObjectUUID()); writer.putInt(0); - writer.putInt(i.getTemplsteID()); + writer.putInt(i.getTemplateID()); writer.putInt(template.item_value); long timeLife = i.getDateToUpgrade() - System.currentTimeMillis(); timeLife /= 1000; writer.putInt((int) timeLife); - writer.putInt(npc.getRollingTimeInSeconds(i.getTemplsteID())); + writer.putInt(npc.getRollingTimeInSeconds(i.getTemplateID())); writer.putInt(1); if (i.isComplete()) diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 34b54ab7..ad85bf01 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -52,7 +52,7 @@ public class Item extends AbstractWorldObject { private boolean isRandom = false; private int value; public OwnerType ownerType; - public int templsteID; + public int templateID; private AbstractWorldObject lastOwner; private long dateToUpgrade; private String customName = ""; @@ -67,7 +67,7 @@ public class Item extends AbstractWorldObject { public Item(int templateID) { super(); - this.templsteID = templateID; + this.templateID = templateID; this.template = ItemTemplate.itemTemplates.get(templateID); this.chargesRemaining = this.template.item_initial_charges; this.durabilityCurrent = this.template.combat_health_full; @@ -84,11 +84,11 @@ public class Item extends AbstractWorldObject { public Item(ResultSet rs) throws SQLException { super(rs); - this.templsteID = rs.getInt("item_itemBaseID"); - this.template = ItemTemplate.itemTemplates.get(this.templsteID); + this.templateID = rs.getInt("item_itemBaseID"); + this.template = ItemTemplate.itemTemplates.get(this.templateID); if (this.template == null) - Logger.error("Null template of " + this.templsteID) + Logger.error("Null template of " + this.templateID) ; // Set container enumeration @@ -227,7 +227,7 @@ public class Item extends AbstractWorldObject { writer.putInt(0); // Pad writer.putInt(0); // Pad - if (item.getItemBase().equals(ItemBase.GOLD_ITEM_BASE)) { + if (item.templateID == ResourceType.GOLD.templateID) { if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter player = (PlayerCharacter) item.getOwner(); @@ -660,11 +660,11 @@ public class Item extends AbstractWorldObject { } public ItemBase getItemBase() { - return ItemBase.getItemBase(templsteID); + return ItemBase.getItemBase(templateID); } - public int getTemplsteID() { - return this.templsteID; + public int getTemplateID() { + return this.templateID; } public int getOwnerID() { @@ -1012,7 +1012,7 @@ public class Item extends AbstractWorldObject { if (this.customName.isEmpty() == false) return this.customName; - ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplsteID()); + ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplateID()); return template.item_base_name; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 04598be4..9a61156e 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -179,8 +179,8 @@ public class ItemFactory { time = (20 - rate); time *= MBServerStatics.ONE_MINUTE; - if (ml.templsteID > 910010 && ml.templsteID < 910019) { - rank = ml.getTemplsteID() - 910010; + if (ml.templateID > 910010 && ml.templateID < 910019) { + rank = ml.getTemplateID() - 910010; time = rank * 60 * 60 * 3 * 1000; } @@ -201,8 +201,8 @@ public class ItemFactory { if (pc != null) playerID = pc.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, "", "", "", false, playerID); - ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, "", "", "", playerID); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, "", "", "", false, playerID); + ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, "", "", "", playerID); pi.setProducedItemID(ml.getObjectUUID()); pi.setAmount(itemsToRoll); pi.setRandom(false); @@ -589,7 +589,7 @@ public class ItemFactory { time *= MBServerStatics.ONE_MINUTE; if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) { - rank = ml.getTemplsteID() - 910010; + rank = ml.getTemplateID() - 910010; time = rank * 60 * 60 * 3 * 1000; } @@ -610,8 +610,8 @@ public class ItemFactory { if (pc != null) playerID = pc.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID); - ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID); + ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID); pi.setProducedItemID(ml.getObjectUUID()); pi.setAmount(itemsToRoll); @@ -728,7 +728,7 @@ public class ItemFactory { time *= MBServerStatics.ONE_MINUTE; if (toRoll.getItemBase().getUUID() > 910010 && toRoll.getItemBase().getUUID() < 910019) { - rank = toRoll.getTemplsteID() - 910010; + rank = toRoll.getTemplateID() - 910010; time = rank * 60 * 60 * 3 * 1000; } @@ -748,9 +748,9 @@ public class ItemFactory { if (playerCharacter != null) playerID = playerCharacter.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID); + DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID); - ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID); + ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID); pi.setProducedItemID(toRoll.getObjectUUID()); pi.setAmount(itemsToRoll); ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 959729a7..c3ae4e39 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -223,7 +223,7 @@ public class Warehouse extends AbstractWorldObject { return false; } - Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templsteID); + Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templateID); if (warehouse.resources.get(resourceType) == null) return false; @@ -251,7 +251,7 @@ public class Warehouse extends AbstractWorldObject { int newAmount = oldAmount + amount; - if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templsteID).deposit_limit) { + if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templateID).deposit_limit) { //ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource."); return false; } @@ -293,7 +293,7 @@ public class Warehouse extends AbstractWorldObject { if (resource.template.item_type.equals(Enum.ItemType.GOLD)) resourceType = Enum.ResourceType.GOLD; else - resourceType = Enum.ResourceType.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase()); + resourceType = Enum.ResourceType.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplateID()).item_base_name.toUpperCase()); if (transaction) AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);