diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 3b6ebcc3..33280cf9 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -15,7 +15,7 @@ import engine.gameManager.ZoneManager; import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.AbstractCharacter; -import engine.objects.ItemBase; +import engine.objects.Item; import engine.objects.Shrine; import engine.objects.Zone; import engine.powers.EffectsBase; @@ -560,94 +560,47 @@ public class Enum { } } - // Enum for ItemBase flags public enum ItemType { - UNKNOWN(0), - WEAPON(1), - ARMOR(2), - BASE(3), - GOLD(4), - SCROLL(5), - BOOK(6), - WAND(7), - POTION(8), - KEY(9), - CHARTER(10), - GUILDTREE(11), - SOUNDSOURCE(12), - JEWELRY(13), - CONTAINER(14), - FOUNTAIN(15), - FOOD(16), - DRINKCONTAINER(17), - MAPMARKER(18), - DEED(19), - EMPLOYMENTCONTRACT(20), - PETTOTEM(21), - SLAVECOLLAR(22), - BLANKKEY(23), - WARRANT(24), - FURNITUREDEED(25), - TENT(26), - REAGENT(27), - DEVICE(28), - FORMULA(29), - BUCKET(30), - TREASURE(31), - RUNE(32), - OFFERING(33), - RESOURCE(34), - REALMCHARTER(35), - // old itembase support - DECORATION(0), - HAIR(3), - COMMANDROD(7), - TEARS(8), - GUILDCHARTER(10), - WINE(16), - ALEJUG(17), - CONTRACT(20), - PET(21), - FURNITURE(25), - BEDROLL(26), - FARMABLE(27), - WATERBUCKET(30), - GIFT(31); - - private final static HashMap _typeLookup = new HashMap<>(); - private final int _value; - - ItemType(int value) { - this._value = value; - } - - public static ItemType getByValue(int value) { - - ItemType outType = ItemType.DECORATION; - - if (_typeLookup.isEmpty()) { - - for (ItemType itemType : ItemType.values()) { - _typeLookup.put(itemType._value, itemType); - } - } - - if (_typeLookup.containsKey(value)) - outType = _typeLookup.get(value); - - return outType; - } - - /** - * @return the _value - */ - public int getValue() { - return _value; - } - + DECORATION, + WEAPON, + ARMOR, + BASE, + GOLD, + SCROLL, + BOOK, + WAND, + POTION, + KEY, + CHARTER, + GUILDTREE, + SOUNDSOURCE, + JEWELRY, + CONTAINER, + FOUNTAIN, + FOOD, + DRINKCONTAINER, + MAPMARKER, + DEED, + EMPLOYMENTCONTRACT, + PETTOTEM, + SLAVECOLLAR, + BLANKKEY, + WARRANT, + FURNITUREDEED, + TENT, + REAGENT, + DEVICE, + FORMULA, + BUCKET, + TREASURE, + RUNE, + OFFERING, + RESOURCE, + REALMCHARTER; } + // Enum to derive effects for active spires from blueprintUUID public enum SpireType { @@ -2493,16 +2446,16 @@ public class Enum { this.sexRequired = sexRequired; } - public static GuildCharterType getGuildTypeFromCharter(ItemBase itemBase) { + public static GuildCharterType getGuildTypeFromCharter(Item charter) { GuildCharterType charterType; // Must be a valid charter object - if (itemBase.getType().equals(ItemType.GUILDCHARTER) == false) + if (charter.template.item_type.equals(ItemType.CHARTER) == false) return GuildCharterType.NONE; //No guild Type - switch (itemBase.getUUID()) { + switch (charter.template.template_id) { case 559: charterType = GuildCharterType.CATHEDRAL; diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index d06fe9b2..a9900971 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -294,7 +294,7 @@ public class dbItemHandler extends dbHandlerBase { for (Item item : inventory) { - if (item.getItemBase().getType().equals(ItemType.GOLD)) + if (item.template.item_type.equals(ItemType.GOLD)) continue; try (Connection connection = DbManager.getConnection(); @@ -438,7 +438,7 @@ public class dbItemHandler extends dbHandlerBase { */ public boolean UPDATE_GOLD(final Item item, int newValue, int oldValue) { - if (!item.getItemBase().getType().equals(ItemType.GOLD)) + if (!item.template.item_type.equals(ItemType.GOLD)) return false; try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index 656f3a8f..24a78301 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -57,8 +57,8 @@ public class SimulateBootyCmd extends AbstractDevCmd { try { mob.loadInventory(); for (Item lootItem : mob.getCharItemManager().getInventory()) { - switch (lootItem.getItemBase().getType()) { - case CONTRACT: //CONTRACT + switch (lootItem.template.item_type) { + case EMPLOYMENTCONTRACT: //CONTRACT Contracts.add(lootItem); break; case OFFERING: //OFFERING diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 12776431..9c8d607f 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -51,7 +51,7 @@ public enum CombatManager { // if you carry something in the offhand thats a weapon you get to swing it if (weaponOff != null) - if (weaponOff.getItemBase().getType().equals(ItemType.WEAPON)) + if (weaponOff.template.item_type.equals(ItemType.WEAPON)) swingOffhand = true; // if you carry nothing in either hand you get to swing your offhand @@ -320,7 +320,7 @@ public enum CombatManager { else { ItemBase ib = weapon.getItemBase(); - if (ib == null || !ib.getType().equals(ItemType.WEAPON)) + if (ib == null || !weapon.template.item_type.equals(ItemType.WEAPON)) isWeapon = false; else wb = ib; @@ -338,7 +338,7 @@ public enum CombatManager { if (weaponOff != null) { ItemBase ib = weaponOff.getItemBase(); - if (ib == null || !ib.getType().equals(ItemType.WEAPON)) + if (ib == null || !weaponOff.template.item_type.equals(ItemType.WEAPON)) hasNoWeapon = true; else return 1; //no need to attack with this hand @@ -904,7 +904,7 @@ public enum CombatManager { if (ib == null) return false; - if (ib.getType().equals(ItemType.WEAPON) == false) + if (item.template.item_type.equals(ItemType.WEAPON) == false) return false; return ib.getRange() > MBServerStatics.RANGED_WEAPON_RANGE; diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index c75c935d..216e859c 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -175,14 +175,12 @@ public enum LootManager { if (itemUUID == 0) return null; - if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + if (ItemTemplate.itemTemplates.get(itemUUID).item_type.equals(Enum.ItemType.RESOURCE)) { int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1); return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false); } outItem = new MobLoot(mob, ItemBase.getItemBase(itemUUID), false); - Enum.ItemType outType = outItem.getItemBase().getType(); - if(selectedRow.pModTable != 0){ try { diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index d55d04b0..22e4acc2 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -2502,12 +2502,12 @@ public enum PowersManager { if (pb.targetItem()) return true; // TODO add these checks later - else if (pb.targetArmor() && item.getItemBase().getType().equals(ItemType.ARMOR)) + else if (pb.targetArmor() && item.template.item_type.equals(ItemType.ARMOR)) return true; - else if (pb.targetJewelry() && item.getItemBase().getType().equals(ItemType.JEWELRY)) + else if (pb.targetJewelry() && item.template.item_type.equals(ItemType.JEWELRY)) return true; else - return pb.targetWeapon() && item.getItemBase().getType().equals(ItemType.WEAPON); + return pb.targetWeapon() && item.template.item_type.equals(ItemType.WEAPON); } // How did we get here? all valid targets have been covered else return false; diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 98642c7b..32b6ca8f 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -219,7 +219,7 @@ public class ClientMessagePump implements NetMsgHandler { return; if (item.containerType == ItemContainerType.INVENTORY && itemManager.isBankOpen()) - if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { + if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { if (!itemManager.moveGoldToBank(item, msg.getNumItems())) return; UpdateGoldMsg goldMes = new UpdateGoldMsg(player); @@ -274,7 +274,7 @@ public class ClientMessagePump implements NetMsgHandler { if (item.containerType == ItemContainerType.BANK && itemManager.isBankOpen() == false) return; - if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { + if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { if (!itemManager.moveGoldToInventory(item, msg.getNumItems())) return; @@ -738,7 +738,7 @@ public class ClientMessagePump implements NetMsgHandler { return; - if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { + if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { // this is done to prevent the temporary goldItem item // (from the mob) from appearing in player's inventory. // It also updates the goldItem quantity display @@ -769,7 +769,7 @@ public class ClientMessagePump implements NetMsgHandler { //TODO send group loot message if player is grouped and visible Group group = GroupManager.getGroup(player); - if (group != null && group.getSplitGold() && (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD) == false)) { + if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) { String name = item.getName(); String text = player.getFirstName() + " has looted " + name + '.'; ChatManager.chatGroupInfoCanSee(player, text); @@ -787,7 +787,7 @@ public class ClientMessagePump implements NetMsgHandler { return; } - if (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) { + if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { // this is done to prevent the temporary goldItem item // (from the mob) from appearing in player's inventory. // It also updates the goldItem quantity display @@ -826,7 +826,7 @@ public class ClientMessagePump implements NetMsgHandler { //TODO send group loot message if player is grouped and visible Group group = GroupManager.getGroup(player); - if (group != null && group.getSplitGold() && (item.getItemBase().getType().equals(engine.Enum.ItemType.GOLD) == false)) { + if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) { String name = item.getName(); String text = player.getFirstName() + " has looted " + name + '.'; ChatManager.chatGroupInfoCanSee(player, text); diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 0d2897bf..a7ea75c6 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -48,9 +48,9 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { // Filter hirelings by slot type for (Item hirelings : player.getInventory()) { - if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) { + if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) { - contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID()); + contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templsteID); if (contract == null) continue; diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index 46663378..147e0381 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -28,7 +28,6 @@ import engine.net.client.msg.guild.GuildCreationFinalizeMsg; import engine.net.client.msg.guild.GuildInfoMsg; import engine.objects.Guild; import engine.objects.Item; -import engine.objects.ItemBase; import engine.objects.PlayerCharacter; import engine.util.StringUtils; @@ -46,7 +45,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { Enum.GuildCharterType charterType; Guild newGuild; Guild playerGuild; - ItemBase itemBase; + Item charter; Dispatch dispatch; @@ -69,16 +68,14 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { return true; } - itemBase = charter.getItemBase(); - // Item must be a valid charterType (type 10 in db) - if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) { + if (charter == null || (charter.template.item_type.equals(ItemType.CHARTER) == false)) { ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND); return true; } - charterType = Enum.GuildCharterType.getGuildTypeFromCharter(itemBase); + charterType = Enum.GuildCharterType.getGuildTypeFromCharter(charter); if (charterType == null) { ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index aca20b90..a1a0a40a 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -126,7 +126,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem == null) return; - if (targetItem.getItemBase().getType() == ItemType.GOLD) + if (targetItem.template.item_type.equals(ItemType.GOLD)) return; if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) { @@ -266,7 +266,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem == null) continue; - if (targetItem.getItemBase().getType() == ItemType.GOLD) + if (targetItem.template.item_type.equals(ItemType.GOLD)) return; if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID())) @@ -281,13 +281,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { break; } - switch (targetItem.getItemBase().getType()) { - case CONTRACT: - case GUILDCHARTER: + switch (targetItem.template.item_type) { + case EMPLOYMENTCONTRACT: + case CHARTER: case DEED: case REALMCHARTER: case SCROLL: - case TEARS: + case POTION: itemValue = 0; continue; } @@ -402,7 +402,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; - if (targetItem.getItemBase().getType() == ItemType.GOLD) + if (targetItem.template.item_type.equals(ItemType.GOLD)) return; if (vendor.getCharItemManager().inventoryContains(targetItem) == false) return; diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index c70c4814..8470bec2 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -315,18 +315,13 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) { - if (ib.isConsumable() || ib.getType() == ItemType.FARMABLE) { + if (ib.isConsumable() || item.template.item_type.equals(ItemType.REAGENT)) { - int uuid = ib.getUUID(); - int type = ib.getType().getValue(); + int uuid = item.templsteID; - switch (type) { - case 27: //Mithril repair - break; - case 10: //charters - //don't think they're handled here? - break; - case 19: //buildings + switch (item.template.item_type) { + + case DEED: //buildings //Call add building screen here, ib.getUseID() get's building ID //if inside player city, center loc on tol. otherwise center on player. @@ -352,10 +347,10 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { //itemMan.consume(item); //temporary fix for dupe.. TODO Make Item Unusable after This message is sent. break; - case 25: //furniture + case FURNITUREDEED: //furniture //Call add furniture screen here. ib.getUseID() get's furniture ID break; - case 33: + case OFFERING: long shrineCompID = comps.get(1); Building shrineBuilding = BuildingManager.getBuilding((int) shrineCompID); if (shrineBuilding == null) { @@ -381,7 +376,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { } break; - case 35: + case REALMCHARTER: int charterType = 0; switch (uuid) { case 910020: @@ -398,7 +393,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { itemMan.consume(item); } break; - case 7: //rod of command + case WAND: //rod of command long compID = comps.get(1); int objectType = AbstractWorldObject.extractTypeID(compID).ordinal(); @@ -422,7 +417,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { } break; //ANNIVERSERY GIFT - case 31: + case TREASURE: // *** Disabled for now: Needs bootyset created //if (ib.getUUID() == 971012) { @@ -440,13 +435,13 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { // break; //} - LootManager.peddleFate(player,item); + LootManager.peddleFate(player, item); break; - case 30: //water bucket - case 8: //potions, tears of saedron + case BUCKET: //water bucket + case POTION: //potions, tears of saedron - case 5: //runes, petition, warrant, scrolls + case SCROLL: //runes, petition, warrant, scrolls if (uuid > 3000 && uuid < 3050) { //Discipline Runes if (ApplyRuneMsg.applyRune(uuid, origin, player)) { itemMan.consume(item); diff --git a/src/engine/net/client/msg/BuyFromNPCWindowMsg.java b/src/engine/net/client/msg/BuyFromNPCWindowMsg.java index 673d22d8..d41619f1 100644 --- a/src/engine/net/client/msg/BuyFromNPCWindowMsg.java +++ b/src/engine/net/client/msg/BuyFromNPCWindowMsg.java @@ -162,7 +162,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg { for (Item item : inventory) { if (item.getOwnerID() != ownerID) continue; - if (item.getItemBase().getType().equals(ItemType.GOLD)) { + if (item.template.item_type.equals(ItemType.GOLD)) { if (item.getNumOfItems() == 0) continue; } diff --git a/src/engine/net/client/msg/UpdateInventoryMsg.java b/src/engine/net/client/msg/UpdateInventoryMsg.java index 5479f14d..da54bc71 100644 --- a/src/engine/net/client/msg/UpdateInventoryMsg.java +++ b/src/engine/net/client/msg/UpdateInventoryMsg.java @@ -54,7 +54,7 @@ public class UpdateInventoryMsg extends ClientNetMsg { for (Item item : list) { - if (item.getItemBase().getType().equals(ItemType.GOLD)) { + if (item.template.item_type.equals(ItemType.GOLD)) { if (item.getNumOfItems() == 0) continue; } diff --git a/src/engine/net/client/msg/UseCharterMsg.java b/src/engine/net/client/msg/UseCharterMsg.java index e31d2522..4f2cadac 100644 --- a/src/engine/net/client/msg/UseCharterMsg.java +++ b/src/engine/net/client/msg/UseCharterMsg.java @@ -63,7 +63,7 @@ public class UseCharterMsg extends ClientNetMsg { if (close) { for (Item i : player.getInventory()) { - if (i.getItemBase().getType().equals(ItemType.GUILDCHARTER)) { + if (i.template.item_type.equals(ItemType.CHARTER)) { charterUUID = i.getObjectUUID(); break; } diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 9f2cde2d..3dae6fca 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -191,19 +191,19 @@ public class CharacterItemManager { } break; case BANK: - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) this.goldBank = i; else if (this.bank.contains(i) == false) this.bank.add(i); break; case INVENTORY: - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) this.goldInventory = i; else if (this.inventory.contains(i) == false) this.inventory.add(i); break; case VAULT: - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) this.goldVault = i; else if (this.vault.contains(i) == false) this.vault.add(i); @@ -238,13 +238,13 @@ public class CharacterItemManager { this.equipped.put(i.equipSlot, i); break; case BANK: - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) this.goldBank = i; else if (this.bank.contains(i) == false) this.bank.add(i); break; case INVENTORY: - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) this.goldInventory = i; else if (this.inventory.contains(i) == false) this.inventory.add(i); @@ -915,7 +915,7 @@ public class CharacterItemManager { if (i == null) return false; - if (i.getItemBase().getType().equals(ItemType.GOLD)) { + if (i.template.item_type.equals(ItemType.GOLD)) { if (this.getGoldInventory() != null) { if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID()) this.goldInventory = null; @@ -945,7 +945,7 @@ public class CharacterItemManager { } private synchronized boolean junk(Item i, boolean updateInventory) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) { + if (i.template.item_type.equals(ItemType.GOLD)) { if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID()) if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) { this.getGoldInventory().setNumOfItems(0); @@ -1000,8 +1000,7 @@ public class CharacterItemManager { if (equippedContains(item)) { fromEquip = true; - ItemBase ib = item.getItemBase(); - if (ib != null && ib.getType().equals(ItemType.GOLD)) + if (item.template.item_type.equals(ItemType.GOLD)) this.absCharacter.cancelOnUnEquip(); } @@ -1211,7 +1210,7 @@ public class CharacterItemManager { // This removes ingame item from inventory for loot. private synchronized boolean removeItemFromInventory(Item i) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) { + if (i.template.item_type.equals(ItemType.GOLD)) { if (i.getObjectUUID() != this.getGoldInventory().getObjectUUID()) return false; if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) { @@ -1234,7 +1233,7 @@ public class CharacterItemManager { // This adds item to inventory for loot. Validity checks already handled public synchronized boolean addItemToInventory(Item i) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) if (this.absCharacter.getObjectType() == GameObjectType.Mob) { if (this.goldInventory == null) loadGoldItems(); @@ -1261,7 +1260,7 @@ public class CharacterItemManager { //called for adding gold of a specified amount public synchronized boolean addItemToInventory(Item i, int amount) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) return DbManager.ItemQueries.UPDATE_GOLD(this.getGoldInventory(), this.goldInventory.getNumOfItems() + amount); return false; } @@ -1623,9 +1622,9 @@ public class CharacterItemManager { synchronized (lockFirst) { synchronized (lockSecond) { // make sure current player has item in inventory - if (lootItem.getItemBase().getType().equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob))) + if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob))) return null; - else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.getItemBase().getType().equals(ItemType.GOLD)) + else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD)) return null; // get weight of item @@ -1636,10 +1635,10 @@ public class CharacterItemManager { int weight = lootItem.template.item_wt; // make sure lootingPlayer has room for item - if (!lootItem.getItemBase().getType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight)) + if (!lootItem.template.item_type.equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight)) return null; - if (lootItem.getItemBase().getType().equals(ItemType.GOLD)) + if (lootItem.template.item_type.equals(ItemType.GOLD)) if (amount != -1) { //from steal int total = lootItem.getNumOfItems(); amount = (amount > total) ? total : amount; @@ -1702,25 +1701,25 @@ public class CharacterItemManager { * Delegates */ public synchronized boolean bankContains(Item i) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == i.getObjectUUID()); return bank.contains(i); } public synchronized boolean inventoryContains(Item i) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); return inventory.contains(i); } public synchronized boolean forgeContains(Item i, NPC vendor) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); return vendor.getRolling().contains(i); } public synchronized boolean vaultContains(Item i) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.template.item_type.equals(ItemType.GOLD)) return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == i.getObjectUUID()); return this.account.getVault().contains(i); } @@ -2004,13 +2003,13 @@ public class CharacterItemManager { item.zeroItem(); item.containerType = Enum.ItemContainerType.INVENTORY; - if (item.getItemBase().getType().equals(ItemType.GOLD)) + if (item.template.item_type.equals(ItemType.GOLD)) //only add gold item once if (!corpse.hasGold()) corpse.setHasGold(true); newInventory.add(item); } else //item - if (item.getItemBase().getType().equals(ItemType.GOLD)) { + if (item.template.item_type.equals(ItemType.GOLD)) { int amt = item.getNumOfItems(); item.setNumOfItems(0); MobLoot ml = new MobLoot(this.absCharacter, amt); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 5458f521..24838310 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -280,7 +280,7 @@ public class Item extends AbstractWorldObject { writer.put((byte) 0); - if (item.getItemBase().getType().getValue() != 20) { + if (item.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT) == false) { writer.putShort((short) 0); return; } @@ -459,7 +459,7 @@ public class Item extends AbstractWorldObject { int serialized = 0; for (Item item : list) { - if (item.getItemBase().getType().equals(ItemType.GOLD)) + if (item.template.item_type.equals(ItemType.GOLD)) if (item.numberOfItems == 0) continue; try { @@ -493,7 +493,7 @@ public class Item extends AbstractWorldObject { int serialized = 0; for (Item item : list) { - if (item.getItemBase().getType().equals(ItemType.GOLD)) + if (item.template.item_type.equals(ItemType.GOLD)) if (item.numberOfItems == 0) continue; try { diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 36d9efed..e4776ceb 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -30,8 +30,6 @@ public class ItemBase { private static final ArrayList _resourceList = new ArrayList<>(); public final int uuid; -//requirements/restrictions - private final ItemType type; private final int modTable; private final int useID; private int hashID; @@ -61,8 +59,6 @@ public class ItemBase { public ItemBase(ResultSet rs) throws SQLException { this.uuid = rs.getInt("ID"); - - this.type = ItemType.valueOf(rs.getString("Type")); this.useID = rs.getInt("useID"); this.useAmount = rs.getByte("useAmount"); this.modTable = rs.getInt("modTable"); @@ -84,18 +80,17 @@ public class ItemBase { this.twoHanded = (rs.getInt("twoHanded") == 1); - switch (this.type) { + switch (ItemTemplate.itemTemplates.get(this.getUUID()).item_type) { case RUNE: case SCROLL: - case COMMANDROD: + case WAND: case POTION: - case TEARS: - case GUILDCHARTER: + case CHARTER: case DEED: - case CONTRACT: - case WATERBUCKET: + case EMPLOYMENTCONTRACT: + case BUCKET: case REALMCHARTER: - case GIFT: + case TREASURE: this.isConsumable = true; break; case OFFERING: @@ -118,7 +113,7 @@ public class ItemBase { _itemBaseByUUID.put(itemBase.uuid, itemBase); - if (itemBase.type.equals(ItemType.RESOURCE)) + if (ItemTemplate.itemTemplates.get(itemBase.uuid).item_type.equals(ItemType.RESOURCE)) _resourceList.add(itemBase); ItemTemplate template = ItemTemplate.itemTemplates.get(itemBase.uuid); @@ -225,10 +220,6 @@ public class ItemBase { } - public ItemType getType() { - return this.type; - } - public int getUseID() { return this.useID; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index b23ae38e..ca048ea2 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -220,7 +220,7 @@ public class ItemFactory { int suffixCost = 0; - if (ib.getType() == ItemType.WEAPON && ib.getPercentRequired() == 110) { + if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) { switch (ib.getSkillRequired()) { case "Bow": case "Crossbow": @@ -814,7 +814,7 @@ public class ItemFactory { int galvorAmount = 0; int wormwoodAmount = 0; - if (ib.getType() == ItemType.WEAPON && ib.getPercentRequired() == 110) { + if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) { switch (ib.getSkillRequired()) { case "Bow": case "Crossbow": diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e60ce4e4..69a1c315 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1295,7 +1295,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { if (ib == null) return 0; - if (!ib.getType().equals(ItemType.ARMOR)) + if (!armor.template.item_type.equals(ItemType.ARMOR)) return 0; if (ib.getSkillRequired().isEmpty()) @@ -1334,7 +1334,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { if (ib == null) noWeapon = true; - else if (ib.getType().equals(ItemType.WEAPON) == false) { + else if (weapon.template.item_type.equals(ItemType.WEAPON) == false) { defaultAtrAndDamage(mainHand); return; } else diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index 0f84a863..4c158c12 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -69,7 +69,7 @@ public final class MobLoot extends Item { this.ownerID = mob.getObjectUUID(); this.objectUUID = generateId(); - if (quantity == 0 && ib.getType() == ItemType.RESOURCE) + if (quantity == 0 && ItemTemplate.itemTemplates.get(ib.getUUID()).item_type == ItemType.RESOURCE) quantity = 1; if (quantity > 0) @@ -129,10 +129,9 @@ public final class MobLoot extends Item { if (isDeleted) return null; - if (this.getItemBase().getType().equals(ItemType.GOLD)) + if (this.template.item_type.equals(ItemType.GOLD)) return null; - Item item = (Item) this; item.setOwner(looter); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index b2786275..8373537f 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1070,7 +1070,7 @@ public class NPC extends AbstractCharacter { ItemBase itemBase; for (Integer itemID : fullItemList) { itemBase = ItemBase.getItemBase(itemID); - boolean exclude = itemBase.getPercentRequired() == 0 && itemBase.getType() == ItemType.WEAPON; + boolean exclude = itemBase.getPercentRequired() == 0 && ItemTemplate.itemTemplates.get(itemID).item_type == ItemType.WEAPON; if (itemBase.getPercentRequired() <= maxSkill && !exclude) filteredItemList.add(itemID); } @@ -1095,7 +1095,7 @@ public class NPC extends AbstractCharacter { if (ib == null) return 0; - if (ib.getType() == ItemType.SCROLL) + if (ItemTemplate.itemTemplates.get(itemID).item_type == ItemType.SCROLL) return this.getRank() * 60 * 60 * 3; float time; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 38e6ff2b..7ded1e94 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2840,11 +2840,11 @@ public class PlayerCharacter extends AbstractCharacter { ItemBase ib = item.getItemBase(); if (ib != null) { - if ((ib.getType().equals(ItemType.WEAPON)) + if ((item.template.item_type.equals(ItemType.WEAPON)) && (ib.getSkillRequired().equals(type) || ib.getMastery().equals(type))) return true; - return (ib.getType().equals(ItemType.ARMOR)) + return (item.template.item_type.equals(ItemType.ARMOR)) && (ib.getSkillRequired().equals(type)); } @@ -3865,7 +3865,7 @@ public class PlayerCharacter extends AbstractCharacter { ItemBase ib = weapon.getItemBase(); if (ib == null) noWeapon = true; - else if (!ib.getType().equals(ItemType.WEAPON)) { + else if (!weapon.template.item_type.equals(ItemType.WEAPON)) { defaultAtrAndDamage(mainHand); return; } else @@ -3884,7 +3884,7 @@ public class PlayerCharacter extends AbstractCharacter { if (noWeapon) { if (mainHand) { Item off = this.charItemManager.getEquipped().get(EquipSlotType.LHELD); - if (off != null && off.getItemBase() != null && off.getItemBase().getType().equals(ItemType.WEAPON)) + if (off != null && off.getItemBase() != null && off.template.item_type.equals(ItemType.WEAPON)) this.rangeHandOne = 10 * (1 + (this.statStrBase / 600)); // Set // to // no @@ -4026,7 +4026,7 @@ public class PlayerCharacter extends AbstractCharacter { //if duel wielding, cut damage by 30% if (otherHand != null) { ItemBase ibo = otherHand.getItemBase(); - if (ibo != null && ibo.getType().equals(ItemType.WEAPON)) { + if (ibo != null && otherHand.template.equals(ItemType.WEAPON)) { min *= 0.7f; max *= 0.7f; } @@ -4171,10 +4171,12 @@ public class PlayerCharacter extends AbstractCharacter { if (ib == null) return 0; - if (!ib.getType().equals(ItemType.ARMOR)) + if (!armor.template.item_type.equals(ItemType.ARMOR)) return 0; + if (ib.getSkillRequired().isEmpty()) return ib.getDefense(); + CharacterSkill armorSkill = this.skills.get(ib.getSkillRequired()); if (armorSkill == null) { Logger.error("Player " + this.getObjectUUID() diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 04b32ec6..59778be3 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -341,7 +341,7 @@ public class Warehouse extends AbstractWorldObject { Resource resourceType; - if (resource.getItemBase().getType().equals(Enum.ItemType.GOLD)) + if (resource.template.item_type.equals(Enum.ItemType.GOLD)) resourceType = Resource.GOLD; else resourceType = Resource.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase()); diff --git a/src/engine/powers/poweractions/StealPowerAction.java b/src/engine/powers/poweractions/StealPowerAction.java index 545137d1..62426407 100644 --- a/src/engine/powers/poweractions/StealPowerAction.java +++ b/src/engine/powers/poweractions/StealPowerAction.java @@ -156,7 +156,7 @@ public class StealPowerAction extends AbstractPowerAction { if (myCIM == null || ownerCIM == null) return; - if (tar.getItemBase().getType().equals(ItemType.GOLD)) { + if (tar.template.item_type.equals(ItemType.GOLD)) { //stealing gold if (!myCIM.transferGoldToMyInventory((AbstractCharacter) owner, amount)) return;