From 61c4cb136124cf3a48bac1acb747bbc4f24afada Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 18 Mar 2024 10:01:29 -0400 Subject: [PATCH] Start mobequip refactor --- src/engine/db/handlers/dbContractHandler.java | 20 +-- src/engine/devcmd/cmds/AddGoldCmd.java | 10 +- src/engine/devcmd/cmds/EnchantCmd.java | 2 +- src/engine/devcmd/cmds/InfoCmd.java | 2 +- src/engine/devcmd/cmds/MakeItemCmd.java | 2 +- src/engine/devcmd/cmds/PrintBankCmd.java | 2 +- src/engine/devcmd/cmds/PrintEquipCmd.java | 10 +- src/engine/devcmd/cmds/PrintInventoryCmd.java | 2 +- src/engine/devcmd/cmds/PrintVaultCmd.java | 2 +- src/engine/devcmd/cmds/SetNpcEquipSetCmd.java | 136 ------------------ src/engine/devcmd/cmds/SimulateBootyCmd.java | 2 +- src/engine/gameManager/BuildingManager.java | 4 +- src/engine/gameManager/DevCmdManager.java | 1 - .../gameManager/FinalCombatManager.java | 12 +- src/engine/gameManager/GroupManager.java | 4 +- src/engine/gameManager/LootManager.java | 20 +-- src/engine/gameManager/PowersManager.java | 2 +- src/engine/gameManager/TradeManager.java | 14 +- src/engine/mobileAI/MobAI.java | 2 +- src/engine/net/client/ClientMessagePump.java | 22 +-- .../handlers/ActivateNPCMsgHandler.java | 4 +- .../client/handlers/BuyFromNPCMsgHandler.java | 6 +- .../GuildCreationFinalizeHandler.java | 8 +- .../handlers/ItemProductionMsgHandler.java | 28 ++-- .../handlers/ObjectActionMsgHandler.java | 2 +- .../client/handlers/OrderNPCMsgHandler.java | 8 +- .../client/handlers/PlaceAssetMsgHandler.java | 20 +-- .../net/client/handlers/RepairMsgHandler.java | 6 +- .../TransferGoldToFromBuildingMsgHandler.java | 7 +- ...ansferItemFromEquipToInventoryHandler.java | 7 +- ...ansferItemFromInventoryToEquipHandler.java | 7 +- .../net/client/msg/BuyFromNPCWindowMsg.java | 4 +- src/engine/net/client/msg/LootMsg.java | 2 +- src/engine/net/client/msg/RefineMsg.java | 2 +- .../net/client/msg/ShowBankInventoryMsg.java | 2 +- src/engine/net/client/msg/TrainMsg.java | 16 +-- src/engine/net/client/msg/UpdateGoldMsg.java | 7 +- .../net/client/msg/UpdateTradeWindowMsg.java | 4 +- .../net/client/msg/VendorDialogMsg.java | 4 +- src/engine/objects/AbstractCharacter.java | 6 +- src/engine/objects/Account.java | 14 +- src/engine/objects/CharacterItemManager.java | 42 +++--- src/engine/objects/Corpse.java | 4 +- src/engine/objects/Item.java | 12 +- src/engine/objects/ItemFactory.java | 6 +- src/engine/objects/MobBase.java | 5 +- src/engine/objects/MobLoot.java | 4 +- src/engine/objects/NPC.java | 19 +-- src/engine/objects/PlayerCharacter.java | 2 +- src/engine/objects/Resists.java | 4 +- src/engine/objects/Shrine.java | 6 +- src/engine/objects/Warehouse.java | 12 +- src/engine/powers/EffectsBase.java | 4 +- .../poweractions/SetItemFlagPowerAction.java | 2 +- .../powers/poweractions/StealPowerAction.java | 14 +- src/engine/server/world/WorldServer.java | 4 +- 56 files changed, 198 insertions(+), 377 deletions(-) delete mode 100644 src/engine/devcmd/cmds/SetNpcEquipSetCmd.java diff --git a/src/engine/db/handlers/dbContractHandler.java b/src/engine/db/handlers/dbContractHandler.java index 0b5e728e..211399bb 100644 --- a/src/engine/db/handlers/dbContractHandler.java +++ b/src/engine/db/handlers/dbContractHandler.java @@ -65,27 +65,9 @@ public class dbContractHandler extends dbHandlerBase { int templateID = rs.getInt("itembaseID"); - Item me = new Item(ItemTemplate.templates.get(templateID), Enum.EquipSlotType.NONE, 0); + Item me = new Item(templateID); contract.getSellInventory().add(me); - //handle magic effects - - String prefix = rs.getString("prefix"); - int pRank = rs.getInt("pRank"); - - String suffix = rs.getString("suffix"); - int sRank = rs.getInt("sRank"); - - if (prefix != null) { - me.setPrefix(prefix, pRank); - me.setIsID(true); - } - - if (suffix != null) { - me.setSuffix(suffix, sRank); - me.setIsID(true); - } - } } catch (SQLException e) { Logger.error(e); diff --git a/src/engine/devcmd/cmds/AddGoldCmd.java b/src/engine/devcmd/cmds/AddGoldCmd.java index e998fc5b..03da03e4 100644 --- a/src/engine/devcmd/cmds/AddGoldCmd.java +++ b/src/engine/devcmd/cmds/AddGoldCmd.java @@ -11,9 +11,7 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ChatManager; -import engine.objects.AbstractGameObject; -import engine.objects.Item; -import engine.objects.PlayerCharacter; +import engine.objects.*; /** * @author Eighty @@ -32,7 +30,7 @@ public class AddGoldCmd extends AbstractDevCmd { return; } - Item gold = pc.getCharItemManager().getGoldInventory(); + Item gold = pc.charItemManager.getGoldInventory(); int curAmt; if (gold == null) curAmt = 0; @@ -54,13 +52,13 @@ public class AddGoldCmd extends AbstractDevCmd { return; } - if (!pc.getCharItemManager().addGoldToInventory(amt, true)) { + if (!pc.charItemManager.addGoldToInventory(amt, true)) { throwbackError(pc, "Failed to add gold to inventory"); return; } ChatManager.chatSayInfo(pc, amt + " gold added to inventory"); - pc.getCharItemManager().updateInventory(); + pc.charItemManager.updateInventory(); } @Override diff --git a/src/engine/devcmd/cmds/EnchantCmd.java b/src/engine/devcmd/cmds/EnchantCmd.java index 1f23ae86..a69fad1a 100644 --- a/src/engine/devcmd/cmds/EnchantCmd.java +++ b/src/engine/devcmd/cmds/EnchantCmd.java @@ -43,7 +43,7 @@ public class EnchantCmd extends AbstractDevCmd { return; } - CharacterItemManager cim = pc.getCharItemManager(); + CharacterItemManager cim = pc.charItemManager; if (cim == null) { throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.'); return; diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 5adb69f5..cc86f90d 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -278,7 +278,7 @@ public class InfoCmd extends AbstractDevCmd { output += "Account ID: UNKNOWN"; output += newline; - output += "Inventory Weight:" + (targetPC.getCharItemManager().getInventoryWeight() + targetPC.getCharItemManager().getEquipWeight()); + output += "Inventory Weight:" + (targetPC.charItemManager.getInventoryWeight() + targetPC.charItemManager.getEquipWeight()); output += newline; output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3); output += newline; diff --git a/src/engine/devcmd/cmds/MakeItemCmd.java b/src/engine/devcmd/cmds/MakeItemCmd.java index e8a14c3f..b276080d 100644 --- a/src/engine/devcmd/cmds/MakeItemCmd.java +++ b/src/engine/devcmd/cmds/MakeItemCmd.java @@ -144,7 +144,7 @@ public class MakeItemCmd extends AbstractDevCmd { && (template.item_type.equals(ItemType.OFFERING)) == false) numItems = 1; - CharacterItemManager cim = pc.getCharItemManager(); + CharacterItemManager cim = pc.charItemManager; if (cim == null) { throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.'); diff --git a/src/engine/devcmd/cmds/PrintBankCmd.java b/src/engine/devcmd/cmds/PrintBankCmd.java index b5327df3..fa62bbdb 100644 --- a/src/engine/devcmd/cmds/PrintBankCmd.java +++ b/src/engine/devcmd/cmds/PrintBankCmd.java @@ -47,7 +47,7 @@ public class PrintBankCmd extends AbstractDevCmd { } - CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager(); + CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager; ArrayList list = cim.getBank(); throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); diff --git a/src/engine/devcmd/cmds/PrintEquipCmd.java b/src/engine/devcmd/cmds/PrintEquipCmd.java index 13c23b63..321e27a1 100644 --- a/src/engine/devcmd/cmds/PrintEquipCmd.java +++ b/src/engine/devcmd/cmds/PrintEquipCmd.java @@ -64,8 +64,8 @@ public class PrintEquipCmd extends AbstractDevCmd { if (tar.getObjectType() == GameObjectType.Mob) { Mob tarMob = (Mob) tar; throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); - for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) { - Item equip = tarMob.getEquip().get(slot); + for (Enum.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) { + Item equip = tarMob.charItemManager.equipped.get(slot); throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot); } return; @@ -74,14 +74,14 @@ public class PrintEquipCmd extends AbstractDevCmd { if (tar.getObjectType() == GameObjectType.NPC) { NPC tarMob = (NPC) tar; throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); - for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) { - Item equip = tarMob.getEquip().get(slot); + for (Enum.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) { + Item equip = tarMob.charItemManager.equipped.get(slot); throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot); } return; } - CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager(); + CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager; ConcurrentHashMap list = cim.getEquipped(); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); diff --git a/src/engine/devcmd/cmds/PrintInventoryCmd.java b/src/engine/devcmd/cmds/PrintInventoryCmd.java index 7c5725da..e2b68464 100644 --- a/src/engine/devcmd/cmds/PrintInventoryCmd.java +++ b/src/engine/devcmd/cmds/PrintInventoryCmd.java @@ -60,7 +60,7 @@ public class PrintInventoryCmd extends AbstractDevCmd { } } - CharacterItemManager cim = tar.getCharItemManager(); + CharacterItemManager cim = tar.charItemManager; inventory = cim.getInventory(); //this list can contain gold when tar is a PC that is dead gold = cim.getGoldInventory(); throwbackInfo(pc, " Weight : " + (cim.getInventoryWeight() + cim.getEquipWeight())); diff --git a/src/engine/devcmd/cmds/PrintVaultCmd.java b/src/engine/devcmd/cmds/PrintVaultCmd.java index 25e4a463..12b66d57 100644 --- a/src/engine/devcmd/cmds/PrintVaultCmd.java +++ b/src/engine/devcmd/cmds/PrintVaultCmd.java @@ -46,7 +46,7 @@ public class PrintVaultCmd extends AbstractDevCmd { } - CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager(); + CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager; ArrayList list = cim.getVault(); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); for (Item item : list) { diff --git a/src/engine/devcmd/cmds/SetNpcEquipSetCmd.java b/src/engine/devcmd/cmds/SetNpcEquipSetCmd.java deleted file mode 100644 index 844d6613..00000000 --- a/src/engine/devcmd/cmds/SetNpcEquipSetCmd.java +++ /dev/null @@ -1,136 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.Enum.GameObjectType; -import engine.InterestManagement.WorldGrid; -import engine.devcmd.AbstractDevCmd; -import engine.objects.AbstractGameObject; -import engine.objects.MobBase; -import engine.objects.NPC; -import engine.objects.PlayerCharacter; - -public class SetNpcEquipSetCmd extends AbstractDevCmd { - - public static int lastEquipSetID = 0; - - public SetNpcEquipSetCmd() { - super("setEquipSet"); - this.addCmdString("equipset"); - } - - @Override - protected void _doCmd(PlayerCharacter pc, String[] words, - AbstractGameObject target) { - // Arg Count Check - if (words.length != 1) { - this.sendUsage(pc); - return; - } - - if (target.getObjectType() != GameObjectType.NPC) { - this.sendUsage(pc); - return; - } - - NPC npc = (NPC) target; - - if (words[0].equalsIgnoreCase("next")) { - - if (SetNpcEquipSetCmd.lastEquipSetID >= 1222) - SetNpcEquipSetCmd.lastEquipSetID = 1; - else - SetNpcEquipSetCmd.lastEquipSetID++; - - boolean complete = false; - - while (complete == false) { - complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID); - - if (!complete) { - SetNpcEquipSetCmd.lastEquipSetID++; - if (SetNpcEquipSetCmd.lastEquipSetID >= 1222) - SetNpcEquipSetCmd.lastEquipSetID = 1; - } - } - - if (complete) { - npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID()); - WorldGrid.updateObject(npc); - this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID); - } - - - return; - } - - if (words[0].equalsIgnoreCase("last")) { - - if (SetNpcEquipSetCmd.lastEquipSetID <= 1) - SetNpcEquipSetCmd.lastEquipSetID = 1222; - else - SetNpcEquipSetCmd.lastEquipSetID--; - - boolean complete = false; - - while (complete == false) { - complete = NPC.UpdateEquipSetID(npc, SetNpcEquipSetCmd.lastEquipSetID); - - if (!complete) { - SetNpcEquipSetCmd.lastEquipSetID--; - if (SetNpcEquipSetCmd.lastEquipSetID <= 1) - SetNpcEquipSetCmd.lastEquipSetID = 1222; - } - - } - - if (complete) { - this.throwbackInfo(pc, "Equipment Set Changed to " + SetNpcEquipSetCmd.lastEquipSetID); - npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID()); - WorldGrid.updateObject(npc); - } - - - return; - } - - int equipSetID = 0; - - try { - equipSetID = Integer.parseInt(words[0]); - } catch (Exception e) { - this.throwbackError(pc, e.getMessage()); - } - - if (!NPC.UpdateEquipSetID(npc, equipSetID)) { - this.throwbackError(pc, "Unable to find Equipset for ID " + equipSetID); - return; - } - - SetNpcEquipSetCmd.lastEquipSetID = equipSetID; - npc.equip = MobBase.loadEquipmentSet(npc.getEquipmentSetID()); - WorldGrid.updateObject(npc); - - this.throwbackInfo(pc, "Equipment Set Changed to " + equipSetID); - - - } - - @Override - protected String _getHelpString() { - return "Sets slot position for an NPC to 'slot'"; - } - - @Override - protected String _getUsageString() { - return "' /changeslot slot'"; - } - -} diff --git a/src/engine/devcmd/cmds/SimulateBootyCmd.java b/src/engine/devcmd/cmds/SimulateBootyCmd.java index c0ea143a..dc4817a2 100644 --- a/src/engine/devcmd/cmds/SimulateBootyCmd.java +++ b/src/engine/devcmd/cmds/SimulateBootyCmd.java @@ -56,7 +56,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { try { mob.loadInventory(); - for (Item lootItem : mob.getCharItemManager().getInventory()) { + for (Item lootItem : mob.charItemManager.getInventory()) { switch (lootItem.template.item_type) { case EMPLOYMENTCONTRACT: //CONTRACT Contracts.add(lootItem); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 9475cab7..d7d285da 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -209,7 +209,7 @@ public enum BuildingManager { ItemTemplate template = ItemTemplate.templates.get(1705032); // Elan Stone - if (!player.getCharItemManager().hasRoomInventory(template.item_wt)) + if (!player.charItemManager.hasRoomInventory(template.item_wt)) return false; if (!Item.MakeItemForPlayer(template.template_id, player, amount)) @@ -231,7 +231,7 @@ public enum BuildingManager { for (Enum.ResourceType resourceType : EnumSet.allOf(Enum.ResourceType.class)) { - if (!player.getCharItemManager().hasRoomInventory(resourceType.template.item_wt)) { + if (!player.charItemManager.hasRoomInventory(resourceType.template.item_wt)) { ChatManager.chatSystemInfo(player, "You can not carry any more of that item."); return false; } diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index a32ad819..1178c1be 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -132,7 +132,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new GotoObj()); DevCmdManager.registerDevCmd(new convertLoc()); DevCmdManager.registerDevCmd(new UnloadFurnitureCmd()); - DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd()); DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd()); DevCmdManager.registerDevCmd(new ResetLevelCmd()); DevCmdManager.registerDevCmd(new SetNpcNameCmd()); diff --git a/src/engine/gameManager/FinalCombatManager.java b/src/engine/gameManager/FinalCombatManager.java index 4b74077d..39cc81d6 100644 --- a/src/engine/gameManager/FinalCombatManager.java +++ b/src/engine/gameManager/FinalCombatManager.java @@ -39,8 +39,8 @@ public class FinalCombatManager { return; } - Item mainWeapon = attacker.getCharItemManager().getEquipped().get(Enum.EquipSlotType.RHELD); - Item offWeapon = attacker.getCharItemManager().getEquipped().get(Enum.EquipSlotType.LHELD); + Item mainWeapon = attacker.charItemManager.getEquipped().get(Enum.EquipSlotType.RHELD); + Item offWeapon = attacker.charItemManager.getEquipped().get(Enum.EquipSlotType.LHELD); if(mainWeapon == null && offWeapon == null){ //no weapons equipped, punch with both fists processAttack(attacker,target,Enum.EquipSlotType.RHELD); @@ -71,7 +71,7 @@ public class FinalCombatManager { PlayerBonuses bonus = attacker.getBonuses(); float rangeMod = 1.0f; float attackRange = MBServerStatics.NO_WEAPON_RANGE; - Item weapon = attacker.getCharItemManager().getEquipped(slot); + Item weapon = attacker.charItemManager.getEquipped(slot); if (weapon != null) { if (bonus != null) rangeMod += bonus.getFloatPercentAll(Enum.ModType.WeaponRange, Enum.SourceType.NONE); @@ -123,7 +123,7 @@ public class FinalCombatManager { if (target.getObjectType() == Enum.GameObjectType.Building) hitChance = 100; - int passiveAnim = getSwingAnimation(attacker.getCharItemManager().getEquipped().get(slot).template, null, true); + int passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true); if(ThreadLocalRandom.current().nextInt(100) > hitChance) { TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim); @@ -161,13 +161,13 @@ public class FinalCombatManager { //get the damage type Enum.SourceType damageType; - if(attacker.getCharItemManager().getEquipped().get(slot) == null) { + if(attacker.charItemManager.getEquipped().get(slot) == null) { damageType = Enum.SourceType.CRUSHING; if(attacker.getObjectType().equals(Enum.GameObjectType.Mob)) if(((Mob)attacker).isSiege()) damageType = Enum.SourceType.SIEGE; }else { - damageType = (Enum.SourceType) attacker.getCharItemManager().getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0]; + damageType = (Enum.SourceType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0]; } //get resists diff --git a/src/engine/gameManager/GroupManager.java b/src/engine/gameManager/GroupManager.java index fad20eda..8c2565d1 100644 --- a/src/engine/gameManager/GroupManager.java +++ b/src/engine/gameManager/GroupManager.java @@ -353,7 +353,7 @@ public enum GroupManager { if (item.getObjectType() == Enum.GameObjectType.MobLoot) { if (tar.getObjectType() == Enum.GameObjectType.Mob) { - ((Mob) tar).getCharItemManager().delete(item); + ((Mob) tar).charItemManager.delete(item); } else item.setNumOfItems(0); } else @@ -363,7 +363,7 @@ public enum GroupManager { int amt = (group.isGroupLead(splitPlayer)) ? (amount + dif) : amount; if (amt > 0) - splitPlayer.getCharItemManager().addGoldToInventory(amt, false); + splitPlayer.charItemManager.addGoldToInventory(amt, false); } for (PlayerCharacter splitPlayer : playersSplit) { diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 2f2bba44..85109a77 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -310,7 +310,7 @@ public enum LootManager { if (gold > 0) { MobLoot goldAmount = new MobLoot(mob, gold); - mob.getCharItemManager().addItemToInventory(goldAmount); + mob.charItemManager.addItemToInventory(goldAmount); } } @@ -322,7 +322,7 @@ public enum LootManager { MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone); if (toAdd != null) - mob.getCharItemManager().addItemToInventory(toAdd); + mob.charItemManager.addItemToInventory(toAdd); } catch (Exception e) { //TODO chase down loot generation error, affects roughly 2% of drops @@ -336,24 +336,24 @@ public enum LootManager { return; // safehold guards don't drop their equipment //do equipment here int dropCount = 0; - if (mob.getEquip() != null) - for (Item me : mob.getEquip().values()) { + if (mob.charItemManager.equipped.isEmpty() == false) + for (Item item : mob.charItemManager.equipped.values()) { - if (me.getDropChance() == 0) + if (item.drop_chance == 0) continue; float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - float dropChance = me.getDropChance() * 100; + float dropChance = item.drop_chance * 100; if (equipmentRoll > dropChance) continue; - MobLoot ml = new MobLoot(mob, me.template, false); + MobLoot ml = new MobLoot(mob, item.template, false); if (ml != null && dropCount < 1) { ml.setIsID(true); ml.setDurabilityCurrent((short) ((short) ml.durabilityCurrent - ThreadLocalRandom.current().nextInt(5) + 1)); - mob.getCharItemManager().addItemToInventory(ml); + mob.charItemManager.addItemToInventory(ml); dropCount = 1; //break; // Exit on first successful roll. } @@ -372,7 +372,7 @@ public enum LootManager { MobLoot lootItem = new MobLoot(mob, ItemTemplate.templates.get(bse.templateID), true); if (lootItem != null) - mob.getCharItemManager().addItemToInventory(lootItem); + mob.charItemManager.addItemToInventory(lootItem); } public static void peddleFate(PlayerCharacter playerCharacter, Item gift) { @@ -389,7 +389,7 @@ public enum LootManager { //get the character item manager - CharacterItemManager itemMan = playerCharacter.getCharItemManager(); + CharacterItemManager itemMan = playerCharacter.charItemManager; if (itemMan == null) return; diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 22e4acc2..c7b6324d 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -1520,7 +1520,7 @@ public enum PowersManager { if (owner.getObjectType().equals(GameObjectType.PlayerCharacter) || owner.getObjectType().equals(GameObjectType.Mob)) { AbstractCharacter acOwner = (AbstractCharacter) owner; - CharacterItemManager itemMan = acOwner.getCharItemManager(); + CharacterItemManager itemMan = acOwner.charItemManager; if (itemMan == null) return true; if (itemMan.inventoryContains(item)) { diff --git a/src/engine/gameManager/TradeManager.java b/src/engine/gameManager/TradeManager.java index 15d6e2df..2b6b50e3 100644 --- a/src/engine/gameManager/TradeManager.java +++ b/src/engine/gameManager/TradeManager.java @@ -28,7 +28,7 @@ public enum TradeManager { if (source == null) return; - source.getCharItemManager().tradeRequest(msg); + source.charItemManager.tradeRequest(msg); } @@ -41,7 +41,7 @@ public enum TradeManager { return; try { - source.getCharItemManager().acceptTradeRequest(msg); + source.charItemManager.acceptTradeRequest(msg); } catch (Exception e) { Logger.error(e); // TODO Auto-generated catch block @@ -60,7 +60,7 @@ public enum TradeManager { if (source == null || !source.isAlive()) return; try { - source.getCharItemManager().addItemToTradeWindow(msg); + source.charItemManager.addItemToTradeWindow(msg); } catch (Exception e) { Logger.error(e); @@ -76,7 +76,7 @@ public enum TradeManager { return; - CharacterItemManager sourceItemMan = source.getCharItemManager(); + CharacterItemManager sourceItemMan = source.charItemManager; if (sourceItemMan == null) return; @@ -95,7 +95,7 @@ public enum TradeManager { if (source == null || !source.isAlive()) return; - CharacterItemManager sourceItemMan = source.getCharItemManager(); + CharacterItemManager sourceItemMan = source.charItemManager; if (sourceItemMan == null) return; @@ -115,7 +115,7 @@ public enum TradeManager { if (source == null || !source.isAlive()) return; - CharacterItemManager sourceItemMan = source.getCharItemManager(); + CharacterItemManager sourceItemMan = source.charItemManager; if (sourceItemMan == null) return; @@ -137,7 +137,7 @@ public enum TradeManager { if (source == null) return; - CharacterItemManager sourceItemMan = source.getCharItemManager(); + CharacterItemManager sourceItemMan = source.charItemManager; if (sourceItemMan == null) return; diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 32297837..77903b22 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -783,7 +783,7 @@ public class MobAI { if (!aiAgent.despawned) { - if (aiAgent.getCharItemManager().getInventoryCount() > 0) { + if (aiAgent.charItemManager.getInventoryCount() > 0) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { aiAgent.despawn(); aiAgent.deathTime = System.currentTimeMillis(); diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index de21f2c0..45619f25 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -199,7 +199,7 @@ public class ClientMessagePump implements NetMsgHandler { if (!NPCVaultBankRangeCheck(player, origin, "bank")) return; - CharacterItemManager itemManager = player.getCharItemManager(); + CharacterItemManager itemManager = player.charItemManager; if (itemManager == null) return; @@ -256,7 +256,7 @@ public class ClientMessagePump implements NetMsgHandler { if (!NPCVaultBankRangeCheck(player, origin, "bank")) return; - CharacterItemManager itemManager = player.getCharItemManager(); + CharacterItemManager itemManager = player.charItemManager; if (itemManager == null) return; @@ -400,7 +400,7 @@ public class ClientMessagePump implements NetMsgHandler { private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) { - CharacterItemManager itemManager = origin.getPlayerCharacter().getCharItemManager(); + CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager; int uuid = msg.getUUID(); @@ -689,9 +689,9 @@ public class ClientMessagePump implements NetMsgHandler { if (!GroupManager.goldSplit(player, item, origin, tar)) { - if (tar.getCharItemManager() != null) { + if (tar.charItemManager != null) { - itemRet = tar.getCharItemManager().lootItemFromMe(item, player, origin); + itemRet = tar.charItemManager.lootItemFromMe(item, player, origin); //Take equipment off mob if (tar.getObjectType() == GameObjectType.Mob && itemRet != null) { @@ -699,9 +699,9 @@ public class ClientMessagePump implements NetMsgHandler { if (item != null && item.getObjectType() == GameObjectType.MobLoot) { - for (Item equip : mobTarget.getEquip().values()) { + for (Item equip : mobTarget.charItemManager.equipped.values()) { - TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.slot); + TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.equipSlot); DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip); @@ -1037,7 +1037,7 @@ public class ClientMessagePump implements NetMsgHandler { if (player == null) return; - CharacterItemManager itemMan = player.getCharItemManager(); + CharacterItemManager itemMan = player.charItemManager; if (itemMan == null) return; @@ -1058,14 +1058,14 @@ public class ClientMessagePump implements NetMsgHandler { int cost = 0; - if (npc.getCharItemManager().getInventoryCount() > 150) { + if (npc.charItemManager.getInventoryCount() > 150) { if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID == 0) { ArrayList inv = npc.getInventory(); for (int i = 0; i < 20; i++) { try { Item toRemove = inv.get(i); if (toRemove != null) - npc.getCharItemManager().delete(toRemove); + npc.charItemManager.delete(toRemove); } catch (Exception e) { break; } @@ -1091,7 +1091,7 @@ public class ClientMessagePump implements NetMsgHandler { return; if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0) - if (!npc.getCharItemManager().hasRoomInventory(sell.template.item_wt)) { + if (!npc.charItemManager.hasRoomInventory(sell.template.item_wt)) { ErrorPopupMsg.sendErrorPopup(player, 21); return; diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 8b39734d..944ed06c 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -86,12 +86,12 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { if (contractItem == null) return false; - if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) { + if (!player.charItemManager.doesCharOwnThisItem(contractItem.getObjectUUID())) { Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!"); return false; } - itemMan = player.getCharItemManager(); + itemMan = player.charItemManager; zone = ZoneManager.findSmallestZone(building.getLoc()); diff --git a/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java b/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java index ee1e3bb0..4f3ed69f 100644 --- a/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java +++ b/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java @@ -46,7 +46,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { if (origin.buyLock.tryLock()) { try { - CharacterItemManager itemMan = sourcePlayer.getCharItemManager(); + CharacterItemManager itemMan = sourcePlayer.charItemManager; if (itemMan == null) return true; @@ -123,7 +123,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { } } else if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.Item.ordinal()) { - CharacterItemManager npcCim = npc.getCharItemManager(); + CharacterItemManager npcCim = npc.charItemManager; if (npcCim == null) return true; @@ -189,7 +189,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { } else if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.MobLoot.ordinal()) { - CharacterItemManager npcCim = npc.getCharItemManager(); + CharacterItemManager npcCim = npc.charItemManager; if (npcCim == null) return true; diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index 147e0381..4a09b56d 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -26,9 +26,7 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ErrorPopupMsg; 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.PlayerCharacter; +import engine.objects.*; import engine.util.StringUtils; public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { @@ -131,8 +129,8 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { player.setInnerCouncil(true); player.setFullMember(true); player.setGuildTitle(charterType.getNumberOfRanks() - 1); - player.getCharItemManager().delete(charter); - player.getCharItemManager().updateInventory(); + player.charItemManager.delete(charter); + player.charItemManager.updateInventory(); player.incVer(); DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2)); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index a1a0a40a..ca88fbc4 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -129,18 +129,18 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem.template.item_type.equals(ItemType.GOLD)) return; - if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) { + if (!vendor.charItemManager.hasRoomInventory(targetItem.template.item_wt)) { ErrorPopupMsg.sendErrorPopup(player, 21); return; } - itemMan = origin.getPlayerCharacter().getCharItemManager(); + itemMan = origin.getPlayerCharacter().charItemManager; if (itemMan == null) return; - if (vendor.getCharItemManager().getInventoryWeight() > 500) { + if (vendor.charItemManager.getInventoryWeight() > 500) { ErrorPopupMsg.sendErrorPopup(player, 21); return; } @@ -166,7 +166,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - origin.getPlayerCharacter().getCharItemManager().updateInventory(); + origin.getPlayerCharacter().charItemManager.updateInventory(); } catch (Exception e) { Logger.error(e); } finally { @@ -199,7 +199,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; - if (!vendor.getCharItemManager().forgeContains(targetItem, vendor)) + if (!vendor.charItemManager.forgeContains(targetItem, vendor)) return; boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem); @@ -213,7 +213,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { targetItem.containerType = Enum.ItemContainerType.INVENTORY; targetItem.setOwner(vendor); - vendor.getCharItemManager().addItemToInventory(targetItem); + vendor.charItemManager.addItemToInventory(targetItem); vendor.removeItemFromForge(targetItem); @@ -269,9 +269,9 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem.template.item_type.equals(ItemType.GOLD)) return; - if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID())) + if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) continue; - if (vendor.getCharItemManager().inventoryContains(targetItem) == false) + if (vendor.charItemManager.inventoryContains(targetItem) == false) continue; itemValue = targetItem.template.item_value; @@ -293,7 +293,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } totalValue += itemValue; long start = System.currentTimeMillis(); - vendor.getCharItemManager().recycle(targetItem); + vendor.charItemManager.recycle(targetItem); long end = System.currentTimeMillis(); long timetook = end - start; @@ -347,7 +347,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; - if (!vendor.getCharItemManager().forgeContains(targetItem, vendor)) + if (!vendor.charItemManager.forgeContains(targetItem, vendor)) return; // Cannot junk items without a forge! @@ -404,17 +404,17 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem.template.item_type.equals(ItemType.GOLD)) return; - if (vendor.getCharItemManager().inventoryContains(targetItem) == false) + if (vendor.charItemManager.inventoryContains(targetItem) == false) return; - if (player.getCharItemManager().hasRoomInventory(targetItem.template.item_wt) == false) + if (player.charItemManager.hasRoomInventory(targetItem.template.item_wt) == false) return; - player.getCharItemManager().buyFromNPC(targetItem, vendor); + player.charItemManager.buyFromNPC(targetItem, vendor); } - player.getCharItemManager().updateInventory(); + player.charItemManager.updateInventory(); // Update NPC inventory to client diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index a7e4cd44..711f71ca 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -49,7 +49,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { return true; } - itemMan = player.getCharItemManager(); + itemMan = player.charItemManager; if (itemMan == null) { return true; diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index d282700c..30c7c3c5 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -44,11 +44,11 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { Item item; player = SessionManager.getPlayerCharacter(origin); - itemMan = player.getCharItemManager(); + itemMan = player.charItemManager; contract = hireling.contract; - if (!player.getCharItemManager().hasRoomInventory((short) 1)) { + if (!player.charItemManager.hasRoomInventory((short) 1)) { ErrorPopupMsg.sendErrorPopup(player, 21); return; } @@ -400,7 +400,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { return true; - if (player.getCharItemManager().getTradingWith() != null) { + if (player.charItemManager.getTradingWith() != null) { ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings."); return true; } @@ -512,7 +512,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (!building.getHirelings().containsKey(mob)) return true; - if (player.getCharItemManager().getTradingWith() != null) { + if (player.charItemManager.getTradingWith() != null) { ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings."); return true; } diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 17727592..e4511c40 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -388,7 +388,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { case WAREHOUSE: if (contract == null) break; - if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) + if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID())) break; buildingCreated = placeWarehouse(playerCharacter, origin, msg); break; @@ -396,28 +396,28 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { case BULWARK: if (contract == null) break; - if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) + if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID())) break; buildingCreated = placeSiegeEquip(playerCharacter, origin, msg); break; case SPIRE: if (contract == null) break; - if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) + if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID())) break; buildingCreated = placeSpire(playerCharacter, origin, msg); break; case SHRINE: if (contract == null) break; - if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) + if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID())) break; buildingCreated = placeShrine(playerCharacter, origin, msg); break; case BARRACK: if (contract == null) break; - if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) + if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID())) break; buildingCreated = placeBarrack(playerCharacter, origin, msg); break; @@ -433,7 +433,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { default: if (contract == null) break; - if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) + if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID())) break; buildingCreated = placeSingleBuilding(playerCharacter, origin, msg); break; @@ -448,8 +448,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Remove the appropriate deed. if (buildingCreated == true) if (contract != null) { - playerCharacter.getCharItemManager().delete(contract); - playerCharacter.getCharItemManager().updateInventory(); + playerCharacter.charItemManager.delete(contract); + playerCharacter.charItemManager.updateInventory(); } // Close the window. We're done! @@ -1033,7 +1033,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; - if (player.getCharItemManager().getGoldTrading() > 0) { + if (player.charItemManager.getGoldTrading() > 0) { ErrorPopupMsg.sendErrorPopup(player, 195); return false; } @@ -1050,7 +1050,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // We need to be able to access how much gold a character is carrying - itemMan = player.getCharItemManager(); + itemMan = player.charItemManager; if (itemMan == null) diff --git a/src/engine/net/client/handlers/RepairMsgHandler.java b/src/engine/net/client/handlers/RepairMsgHandler.java index ffa5d564..144b483d 100644 --- a/src/engine/net/client/handlers/RepairMsgHandler.java +++ b/src/engine/net/client/handlers/RepairMsgHandler.java @@ -60,7 +60,7 @@ public class RepairMsgHandler extends AbstractClientMsgHandler { } else if (repairMsg.getMsgType() == 0) { //Request RepairObject - CharacterItemManager itemMan = player.getCharItemManager(); + CharacterItemManager itemMan = player.charItemManager; if (itemMan == null) return true; @@ -116,10 +116,10 @@ public class RepairMsgHandler extends AbstractClientMsgHandler { return true; } - if (player.getCharItemManager().getGoldInventory().getNumOfItems() - cost < 0) + if (player.charItemManager.getGoldInventory().getNumOfItems() - cost < 0) return true; - if (player.getCharItemManager().getGoldInventory().getNumOfItems() - cost > MBServerStatics.PLAYER_GOLD_LIMIT) + if (player.charItemManager.getGoldInventory().getNumOfItems() - cost > MBServerStatics.PLAYER_GOLD_LIMIT) return true; if (!itemMan.buyFromNPC(building, cost, cost)) { diff --git a/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java b/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java index 70ba7486..7f40ce7f 100644 --- a/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java +++ b/src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java @@ -12,10 +12,7 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.PlaceAssetMsg; import engine.net.client.msg.TransferGoldToFromBuildingMsg; import engine.net.client.msg.UpdateGoldMsg; -import engine.objects.Building; -import engine.objects.CharacterItemManager; -import engine.objects.Item; -import engine.objects.PlayerCharacter; +import engine.objects.*; import org.pmw.tinylog.Logger; /* @@ -71,7 +68,7 @@ public class TransferGoldToFromBuildingMsgHandler extends AbstractClientMsgHandl //building.getTimestamps().put(MBServerStatics.STRONGBOX_DELAY_STRING, System.currentTimeMillis() + MBServerStatics.ONE_MINUTE); - itemMan = player.getCharItemManager(); + itemMan = player.charItemManager; goldItem = itemMan.getGoldInventory(); diff --git a/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java b/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java index 70f04fc6..d3c7db27 100644 --- a/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java +++ b/src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java @@ -16,10 +16,7 @@ import engine.net.client.ClientConnection; import engine.net.client.msg.ApplyEffectMsg; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; -import engine.objects.CharacterItemManager; -import engine.objects.Effect; -import engine.objects.Item; -import engine.objects.PlayerCharacter; +import engine.objects.*; import engine.server.MBServerStatics; public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHandler { @@ -38,7 +35,7 @@ public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHa TransferItemFromEquipToInventoryMsg msg = (TransferItemFromEquipToInventoryMsg) baseMsg; - CharacterItemManager itemManager = player.getCharItemManager(); + CharacterItemManager itemManager = player.charItemManager; if (itemManager == null) return true; diff --git a/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java b/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java index e40fd2c3..683112ef 100644 --- a/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java +++ b/src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java @@ -19,10 +19,7 @@ import engine.net.client.msg.ApplyEffectMsg; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; import engine.net.client.msg.TransferItemFromInventoryToEquipMsg; -import engine.objects.CharacterItemManager; -import engine.objects.Effect; -import engine.objects.Item; -import engine.objects.PlayerCharacter; +import engine.objects.*; import engine.server.MBServerStatics; public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHandler { @@ -36,7 +33,7 @@ public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHa PlayerCharacter playerCharacter = origin.getPlayerCharacter(); TransferItemFromInventoryToEquipMsg transferMsg = (TransferItemFromInventoryToEquipMsg) baseMsg; - CharacterItemManager itemManager = playerCharacter.getCharItemManager(); + CharacterItemManager itemManager = playerCharacter.charItemManager; if (itemManager == null) { forceTransferFromEquipToInventory(transferMsg, origin, "Can't find your item manager"); diff --git a/src/engine/net/client/msg/BuyFromNPCWindowMsg.java b/src/engine/net/client/msg/BuyFromNPCWindowMsg.java index c74c41a9..528ffdd2 100644 --- a/src/engine/net/client/msg/BuyFromNPCWindowMsg.java +++ b/src/engine/net/client/msg/BuyFromNPCWindowMsg.java @@ -97,7 +97,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg { ArrayList sellInventory = null; if (npc != null) { - man = npc.getCharItemManager(); + man = npc.charItemManager; Contract contract = npc.getContract(); if (player != null) { float barget = player.getBargain(); @@ -149,7 +149,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg { for (Item Item : sellInventory) { try { - Item.serializeForVendor(Item, writer, sellPercent); + Item._serializeForVendor(Item, writer, sellPercent); } catch (SerializationException se) { continue; } diff --git a/src/engine/net/client/msg/LootMsg.java b/src/engine/net/client/msg/LootMsg.java index 537fc79b..9d13dfae 100644 --- a/src/engine/net/client/msg/LootMsg.java +++ b/src/engine/net/client/msg/LootMsg.java @@ -81,7 +81,7 @@ public class LootMsg extends ClientNetMsg { else if (this.Item != null) try { Item._serializeForClientMsg(this.Item, writer, false); - } catch (SerializationException e) { + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/engine/net/client/msg/RefineMsg.java b/src/engine/net/client/msg/RefineMsg.java index 81968961..bf1e5791 100644 --- a/src/engine/net/client/msg/RefineMsg.java +++ b/src/engine/net/client/msg/RefineMsg.java @@ -82,7 +82,7 @@ public class RefineMsg extends ClientNetMsg { //update player pc.applyBonuses(); - pc.getCharItemManager().RemoveEquipmentFromLackOfSkill(pc, true); + pc.charItemManager.RemoveEquipmentFromLackOfSkill(pc, true); //echo refine message back diff --git a/src/engine/net/client/msg/ShowBankInventoryMsg.java b/src/engine/net/client/msg/ShowBankInventoryMsg.java index cbf1ee58..c85801d6 100644 --- a/src/engine/net/client/msg/ShowBankInventoryMsg.java +++ b/src/engine/net/client/msg/ShowBankInventoryMsg.java @@ -57,7 +57,7 @@ public class ShowBankInventoryMsg extends ClientNetMsg { @Override protected void _serialize(ByteBufferWriter writer) throws SerializationException { - ArrayList bank = pc.getCharItemManager().getBank(); + ArrayList bank = pc.charItemManager.getBank(); writer.put((byte) 1); // static value Item.putList(writer, bank, false, pc.getObjectUUID()); diff --git a/src/engine/net/client/msg/TrainMsg.java b/src/engine/net/client/msg/TrainMsg.java index cb778dcf..8e8cb7b7 100644 --- a/src/engine/net/client/msg/TrainMsg.java +++ b/src/engine/net/client/msg/TrainMsg.java @@ -72,12 +72,12 @@ public class TrainMsg extends ClientNetMsg { if (origin.trainLock.tryLock()) { try { - Item gold = playerCharacter.getCharItemManager().getGoldInventory(); + Item gold = playerCharacter.charItemManager.getGoldInventory(); if (gold == null) return; - if (!gold.validForInventory(origin, playerCharacter, playerCharacter.getCharItemManager())) + if (!gold.validForInventory(origin, playerCharacter, playerCharacter.charItemManager)) return; boolean canTrain = false; @@ -190,7 +190,7 @@ public class TrainMsg extends ClientNetMsg { float profitCost = cost * npc.getSellPercent(playerCharacter); profitCost += .5f; - if (profitCost > playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems()) + if (profitCost > playerCharacter.charItemManager.getGoldInventory().getNumOfItems()) return; Building b = npc.getBuilding(); if (b != null && b.getProtectionState().equals(ProtectionState.NPC)) @@ -201,16 +201,16 @@ public class TrainMsg extends ClientNetMsg { return; } - if (playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems() - profitCost < 0) + if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() - profitCost < 0) return; - if (playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems() - profitCost > MBServerStatics.PLAYER_GOLD_LIMIT) + if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() - profitCost > MBServerStatics.PLAYER_GOLD_LIMIT) return; //attempt to train if (sk.train(playerCharacter)) { - playerCharacter.getCharItemManager().buyFromNPC(b, (int) profitCost, (int) (profitCost - cost)); + playerCharacter.charItemManager.buyFromNPC(b, (int) profitCost, (int) (profitCost - cost)); dispatch = Dispatch.borrow(playerCharacter, msg); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); @@ -253,7 +253,7 @@ public class TrainMsg extends ClientNetMsg { float cost = (int) cp.getTrainingCost(playerCharacter, npc); float profitCost = cost * npc.getSellPercent(playerCharacter); profitCost += .5f; - if (profitCost > playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems()) { + if (profitCost > playerCharacter.charItemManager.getGoldInventory().getNumOfItems()) { // ChatManager.chatSystemError(pc, "You do not have enough gold to train this skill."); return; } @@ -269,7 +269,7 @@ public class TrainMsg extends ClientNetMsg { } if (cp.train(playerCharacter)) { - if (!playerCharacter.getCharItemManager().buyFromNPC(b, (int) profitCost, (int) (profitCost - cost))) + if (!playerCharacter.charItemManager.buyFromNPC(b, (int) profitCost, (int) (profitCost - cost))) ChatManager.chatSystemError(playerCharacter, "Failed to Withdrawl gold from inventory. Contact CCR"); //train succeeded diff --git a/src/engine/net/client/msg/UpdateGoldMsg.java b/src/engine/net/client/msg/UpdateGoldMsg.java index 08feaf8a..ac5df886 100644 --- a/src/engine/net/client/msg/UpdateGoldMsg.java +++ b/src/engine/net/client/msg/UpdateGoldMsg.java @@ -15,10 +15,7 @@ import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; import engine.net.client.Protocol; -import engine.objects.AbstractWorldObject; -import engine.objects.CharacterItemManager; -import engine.objects.Item; -import engine.objects.PlayerCharacter; +import engine.objects.*; /** * Update gold in inventory and/or bank @@ -76,7 +73,7 @@ public class UpdateGoldMsg extends ClientNetMsg { public void configure() { if (this.looter != null && this.looter.getObjectType() == GameObjectType.PlayerCharacter) { - itemManager = ((PlayerCharacter) looter).getCharItemManager(); + itemManager = ((PlayerCharacter) looter).charItemManager; goldInventory = itemManager.getGoldInventory(); this.tradeGold = itemManager.getGoldTrading(); goldBank = itemManager.getGoldBank(); diff --git a/src/engine/net/client/msg/UpdateTradeWindowMsg.java b/src/engine/net/client/msg/UpdateTradeWindowMsg.java index 187993b4..9bf0d9d9 100644 --- a/src/engine/net/client/msg/UpdateTradeWindowMsg.java +++ b/src/engine/net/client/msg/UpdateTradeWindowMsg.java @@ -63,7 +63,7 @@ public class UpdateTradeWindowMsg extends ClientNetMsg { ArrayList trading1 = new ArrayList<>(); - for (int itemID : pc1.getCharItemManager().getTrading()) { + for (int itemID : pc1.charItemManager.getTrading()) { Item item = Item.getFromCache(itemID); if (item == null) continue; @@ -71,7 +71,7 @@ public class UpdateTradeWindowMsg extends ClientNetMsg { } ArrayList trading2 = new ArrayList<>(); - for (int itemID : pc2.getCharItemManager().getTrading()) { + for (int itemID : pc2.charItemManager.getTrading()) { Item item = Item.getFromCache(itemID); if (item == null) continue; diff --git a/src/engine/net/client/msg/VendorDialogMsg.java b/src/engine/net/client/msg/VendorDialogMsg.java index 1ced6074..ae5ce3f5 100644 --- a/src/engine/net/client/msg/VendorDialogMsg.java +++ b/src/engine/net/client/msg/VendorDialogMsg.java @@ -607,7 +607,7 @@ public class VendorDialogMsg extends ClientNetMsg { if (ac == null) return; - CharacterItemManager itemManager = playerCharacter.getCharItemManager(); + CharacterItemManager itemManager = playerCharacter.charItemManager; if (itemManager == null) return; @@ -660,7 +660,7 @@ public class VendorDialogMsg extends ClientNetMsg { if (cc == null) return; - CharacterItemManager itemManager = playerCharacter.getCharItemManager(); + CharacterItemManager itemManager = playerCharacter.charItemManager; if (itemManager == null) return; diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index f19da53a..81c8303d 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -49,7 +49,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; public abstract class AbstractCharacter extends AbstractWorldObject { - protected CharacterItemManager charItemManager; + public CharacterItemManager charItemManager; private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock(); public short level; public AbstractWorldObject combatTarget; @@ -657,10 +657,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { return this.unusedStatPoints; } - public final CharacterItemManager getCharItemManager() { - return this.charItemManager; - } - public final void setDebug( final int value, final boolean toggle diff --git a/src/engine/objects/Account.java b/src/engine/objects/Account.java index cc2cde18..02ab13cb 100644 --- a/src/engine/objects/Account.java +++ b/src/engine/objects/Account.java @@ -214,16 +214,16 @@ public class Account extends AbstractGameObject { } //dupe check - if (!item.validForInventory(origin, player, player.getCharItemManager())) + if (!item.validForInventory(origin, player, player.charItemManager)) return; - if (item.containerType == Enum.ItemContainerType.INVENTORY && player.getCharItemManager().isVaultOpen()) { - if (!player.getCharItemManager().hasRoomVault(item.template.item_wt)) { + if (item.containerType == Enum.ItemContainerType.INVENTORY && player.charItemManager.isVaultOpen()) { + if (!player.charItemManager.hasRoomVault(item.template.item_wt)) { ClientMessagePump.forceTransferFromVaultToInventory(msg, origin, "There is no room in your vault."); return; } - if (player.getCharItemManager().moveItemToVault(item)) { + if (player.charItemManager.moveItemToVault(item)) { this.vault.add(item); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); @@ -245,7 +245,7 @@ public class Account extends AbstractGameObject { return; } - CharacterItemManager itemManager = player.getCharItemManager(); + CharacterItemManager itemManager = player.charItemManager; if (itemManager == null) { ClientMessagePump.forceTransferFromInventoryToVault(msg, origin, "Can't find your item manager."); @@ -300,7 +300,7 @@ public class Account extends AbstractGameObject { if (npc == null) return; - CharacterItemManager itemManager = player.getCharItemManager(); + CharacterItemManager itemManager = player.charItemManager; if (itemManager == null) return; @@ -347,7 +347,7 @@ public class Account extends AbstractGameObject { if (!ClientMessagePump.NPCVaultBankRangeCheck(player, origin, "vault")) return; - CharacterItemManager itemManager = player.getCharItemManager(); + CharacterItemManager itemManager = player.charItemManager; if (itemManager == null) return; diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 7ed53da8..a0c2ab30 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -94,12 +94,12 @@ public class CharacterItemManager { if (template == null) return; - CharacterItemManager itemMan = pc.getCharItemManager(); + CharacterItemManager itemMan = pc.charItemManager; if (itemMan == null) return; - CharacterItemManager npcCim = npc.getCharItemManager(); + CharacterItemManager npcCim = npc.charItemManager; if (npcCim == null) return; @@ -322,7 +322,7 @@ public class CharacterItemManager { return false; } - if (this.getOwner().getCharItemManager().getGoldTrading() > 0) { + if (this.getOwner().charItemManager.getGoldTrading() > 0) { if (this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195); return false; @@ -440,8 +440,8 @@ public class CharacterItemManager { // TODO uncomment this block after we determine when we // setBankOpen(false) and setVaultOpen(false) - CharacterItemManager cim1 = source.getCharItemManager(); - CharacterItemManager cim2 = target.getCharItemManager(); + CharacterItemManager cim1 = source.charItemManager; + CharacterItemManager cim2 = target.charItemManager; if (cim1 == null) return false; @@ -539,7 +539,7 @@ public class CharacterItemManager { return false; - CharacterItemManager toTradeWith = target.getCharItemManager(); + CharacterItemManager toTradeWith = target.charItemManager; if (toTradeWith == null) return false; @@ -603,7 +603,7 @@ public class CharacterItemManager { if (other == null || !other.isAlive()) return false; - CharacterItemManager tradingWith = other.getCharItemManager(); + CharacterItemManager tradingWith = other.charItemManager; if (tradingWith == null) return false; @@ -669,7 +669,7 @@ public class CharacterItemManager { if (other == null || !other.isAlive()) return false; - CharacterItemManager tradingWith = other.getCharItemManager(); + CharacterItemManager tradingWith = other.charItemManager; if (tradingWith == null) return false; @@ -725,7 +725,7 @@ public class CharacterItemManager { if (source == null || !source.isAlive()) return false; - CharacterItemManager sourceItemMan = source.getCharItemManager(); + CharacterItemManager sourceItemMan = source.charItemManager; if (sourceItemMan == null) return false; @@ -768,7 +768,7 @@ public class CharacterItemManager { if (other == null || !other.isAlive()) return false; - CharacterItemManager tradingWith = other.getCharItemManager(); + CharacterItemManager tradingWith = other.charItemManager; if (tradingWith == null) return false; @@ -784,7 +784,7 @@ public class CharacterItemManager { CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID); this.commitTrade(); this.closeTradeWindow(ctwm1, false); - other.getCharItemManager().closeTradeWindow(ctwm2, false); + other.charItemManager.closeTradeWindow(ctwm2, false); } return true; } @@ -797,7 +797,7 @@ public class CharacterItemManager { if (this.getTradingWith().getPlayerCharacter() == null) return false; - CharacterItemManager man2 = this.getTradingWith().getPlayerCharacter().getCharItemManager(); + CharacterItemManager man2 = this.getTradingWith().getPlayerCharacter().charItemManager; Dispatch dispatch; if (man1 == null || man2 == null) @@ -825,7 +825,7 @@ public class CharacterItemManager { if (source == null) return false; - CharacterItemManager sourceItemMan = source.getCharItemManager(); + CharacterItemManager sourceItemMan = source.charItemManager; if (sourceItemMan == null) return false; @@ -851,7 +851,7 @@ public class CharacterItemManager { sourceItemMan.endTrade(); - cc2.getPlayerCharacter().getCharItemManager().closeTradeWindow(msg, false); + cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false); return true; @@ -1149,7 +1149,7 @@ public class CharacterItemManager { if (tar == null) return false; - CharacterItemManager tarCim = tar.getCharItemManager(); + CharacterItemManager tarCim = tar.charItemManager; if (tarCim == null) return false; @@ -1398,7 +1398,7 @@ public class CharacterItemManager { return false; - if (this.getOwner().getCharItemManager().getGoldTrading() > 0) { + if (this.getOwner().charItemManager.getGoldTrading() > 0) { if (this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195); return false; @@ -1437,7 +1437,7 @@ public class CharacterItemManager { if (itemToSell == null || npc == null) return false; - itemMan = npc.getCharItemManager(); + itemMan = npc.charItemManager; if (itemMan == null) return false; @@ -1495,7 +1495,7 @@ public class CharacterItemManager { if (purchasedItem == null || npc == null) return false; - itemMan = npc.getCharItemManager(); + itemMan = npc.charItemManager; if (itemMan == null) return false; @@ -1587,7 +1587,7 @@ public class CharacterItemManager { return null; // get looters item manager - CharacterItemManager looterItems = lootingPlayer.getCharItemManager(); + CharacterItemManager looterItems = lootingPlayer.charItemManager; if (looterItems == null) return null; @@ -2129,7 +2129,7 @@ public class CharacterItemManager { tradeCharacter = this.tradingWith.getPlayerCharacter(); tradeWeight = this.getCarriedWeight() + itemWeight; - tradeWeight = tradeWeight + tradeCharacter.getCharItemManager().getTradingWeight(); + tradeWeight = tradeWeight + tradeCharacter.charItemManager.getTradingWeight(); tradeWeight = tradeWeight - this.getTradingWeight(); return tradeWeight <= (int) playerCharacter.statStrBase * 3; @@ -2311,7 +2311,7 @@ public class CharacterItemManager { } - CharacterItemManager tradingWith = this.getTradingWith().getPlayerCharacter().getCharItemManager(); + CharacterItemManager tradingWith = this.getTradingWith().getPlayerCharacter().charItemManager; if (tradingWith == null) return false; diff --git a/src/engine/objects/Corpse.java b/src/engine/objects/Corpse.java index 7d355d76..ad90cda6 100644 --- a/src/engine/objects/Corpse.java +++ b/src/engine/objects/Corpse.java @@ -274,7 +274,7 @@ public class Corpse extends AbstractWorldObject { } //TODO transfer items from players inventory and trade window to corpse - CharacterItemManager cim = belongsTo.getCharItemManager(); + CharacterItemManager cim = belongsTo.charItemManager; if (cim != null) cim.transferEntireInventory(this.inventory, this, enterWorld); else @@ -287,7 +287,7 @@ public class Corpse extends AbstractWorldObject { return null; //get looters item manager - CharacterItemManager looterItems = looter.getCharItemManager(); + CharacterItemManager looterItems = looter.charItemManager; if (looterItems == null) return null; diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 14aad673..70797a77 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -232,7 +232,7 @@ public class Item extends AbstractWorldObject { if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter player = (PlayerCharacter) item.getOwner(); - int tradingAmount = player.getCharItemManager().getGoldTrading(); + int tradingAmount = player.charItemManager.getGoldTrading(); writer.putInt(item.numberOfItems - tradingAmount); } else writer.putInt(item.numberOfItems); // Amount of gold @@ -334,7 +334,7 @@ public class Item extends AbstractWorldObject { writer.putInt(0); // Pad - writer.putInt(player.getCharItemManager().getGoldTrading()); // Amount of gold + writer.putInt(player.charItemManager.getGoldTrading()); // Amount of gold writer.putInt(0); @@ -347,7 +347,7 @@ public class Item extends AbstractWorldObject { writer.putInt(4); //Non-Magical, grey name writer.putInt(1); writer.putInt(0); // Pad - writer.putInt(player.getCharItemManager().getGoldTrading()); + writer.putInt(player.charItemManager.getGoldTrading()); writer.put((byte) 0); writer.putShort((short) 0); @@ -375,8 +375,8 @@ public class Item extends AbstractWorldObject { if (!itemWorked) return false; - reciever.getCharItemManager().addItemToInventory(item); - reciever.getCharItemManager().updateInventory(); + reciever.charItemManager.addItemToInventory(item); + reciever.charItemManager.updateInventory(); return true; } @@ -515,7 +515,7 @@ public class Item extends AbstractWorldObject { } ++serialized; } - if (player.getCharItemManager().getGoldTrading() > 0) { + if (player.charItemManager.getGoldTrading() > 0) { Item.SerializeTradingGold(player, writer); ++serialized; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 4359726b..3bad16cd 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -36,7 +36,7 @@ public class ItemFactory { return; int max = 20; - CharacterItemManager itemManager = pc.getCharItemManager(); + CharacterItemManager itemManager = pc.charItemManager; ItemTemplate template = ItemTemplate.templates.get(templateID); @@ -96,7 +96,7 @@ public class ItemFactory { if (forge == null) return null; - if (!npc.getCharItemManager().hasRoomInventory(template.item_wt)) { + if (!npc.charItemManager.hasRoomInventory(template.item_wt)) { if (pc != null) ErrorPopupMsg.sendErrorPopup(pc, 21); return null; @@ -646,7 +646,7 @@ public class ItemFactory { if (template == null) return null; - if (!vendor.getCharItemManager().hasRoomInventory(template.item_wt)) { + if (!vendor.charItemManager.hasRoomInventory(template.item_wt)) { if (playerCharacter != null) ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full."); diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index ea71ade8..a4b80dda 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -127,9 +127,10 @@ public class MobBase extends AbstractGameObject { for (BootySetEntry equipmentSetEntry : equipList) { Item item = new Item(equipmentSetEntry.templateID); + item.objectUUID = MobLoot.lastNegativeID.decrementAndGet(); item.drop_chance = equipmentSetEntry.dropChance; - - equip.put(item.slot, Item); + item.equipSlot = item.template.item_eq_slots_or.iterator().next(); + equip.put(item.equipSlot, item); } diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index 4b64cac0..5e43f687 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ public final class MobLoot extends Item { - private static final AtomicInteger LastUsedId = new AtomicInteger(0); + public static final AtomicInteger lastNegativeID = new AtomicInteger(0); private boolean isDeleted = false; private boolean noSteal; @@ -77,7 +77,7 @@ public final class MobLoot extends Item { * @return Id number */ private static int generateId() { - int id = LastUsedId.decrementAndGet(); + int id = lastNegativeID.decrementAndGet(); //TODO Add a way to reclaim disposed IDs if this becomes a problem if (id == (-10000)) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 7b0ba35d..097c050a 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -52,7 +52,6 @@ public class NPC extends AbstractCharacter { private final ArrayList rolling = new ArrayList<>(); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public ArrayList forgedItems = new ArrayList<>(); - public HashMap equip = null; public int runeSetID = 0; public int extraRune2 = 0; protected int loadID; @@ -341,11 +340,11 @@ public class NPC extends AbstractCharacter { // get a copy of the equipped items. - if (npc.equip != null) { - writer.putInt(npc.equip.size()); + if (npc.charItemManager.equipped.isEmpty() == false) { + writer.putInt(npc.charItemManager.equipped.size()); - for (Item me : npc.equip.values()) - Item.serializeForClientMsg(me, writer); + for (Item me : npc.charItemManager.equipped.values()) + Item._serializeForClientMsg(me, writer); } else writer.putInt(0); @@ -913,7 +912,7 @@ public class NPC extends AbstractCharacter { if (equipmentSetID != 0 && LootManager._bootySetMap.get(equipmentSetID) == null) Logger.error("Invalid equipSet: " + equipmentSetID + " contract: " + this.contractUUID + " npc: " + this.getObjectUUID()); - this.equip = loadEquipmentSet(this.equipmentSetID); + this.charItemManager.equipped = loadEquipmentSet(this.equipmentSetID); try { @@ -1241,7 +1240,7 @@ public class NPC extends AbstractCharacter { if (targetItem == null) return false; - if (!this.getCharItemManager().forgeContains(targetItem, this)) + if (!this.charItemManager.forgeContains(targetItem, this)) return false; if (!DbManager.NPCQueries.UPDATE_ITEM_TO_INVENTORY(targetItem.getObjectUUID(), currentID)) @@ -1250,7 +1249,7 @@ public class NPC extends AbstractCharacter { targetItem.setIsID(true); this.rolling.remove(targetItem); - this.getCharItemManager().addItemToInventory(targetItem); + this.charItemManager.addItemToInventory(targetItem); //remove from client forge window @@ -1265,10 +1264,6 @@ public class NPC extends AbstractCharacter { return true; } - public HashMap getEquip() { - return equip; - } - public int getEquipmentSetID() { return equipmentSetID; } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 9f9e5e72..1fa8c33a 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1944,7 +1944,7 @@ public class PlayerCharacter extends AbstractCharacter { Mine.releaseMineClaims(this); - this.getCharItemManager().closeTradeWindow(); + this.charItemManager.closeTradeWindow(); //increment live counter. This is to prevent double kills from casts this.liveCounter++; diff --git a/src/engine/objects/Resists.java b/src/engine/objects/Resists.java index a28eb718..c65fb237 100644 --- a/src/engine/objects/Resists.java +++ b/src/engine/objects/Resists.java @@ -400,9 +400,9 @@ public class Resists { // get resists from equipment if (ac.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { - if (ac.getCharItemManager() != null && ac.getCharItemManager().getEquipped() != null) { + if (ac.charItemManager != null && ac.charItemManager.getEquipped() != null) { float[] phys = {0f, 0f, 0f}; - ConcurrentHashMap equip = ac.getCharItemManager().getEquipped(); + ConcurrentHashMap equip = ac.charItemManager.getEquipped(); // get base physical resists phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.HELM), phys); diff --git a/src/engine/objects/Shrine.java b/src/engine/objects/Shrine.java index ab3380d1..a868841f 100644 --- a/src/engine/objects/Shrine.java +++ b/src/engine/objects/Shrine.java @@ -253,7 +253,7 @@ public class Shrine extends AbstractWorldObject implements Comparable { if (boonItem == null) return false; - if (!boonOwner.getCharItemManager().doesCharOwnThisItem(boonItem.getObjectUUID())) + if (!boonOwner.charItemManager.doesCharOwnThisItem(boonItem.getObjectUUID())) return false; for (ShrineType boonShrineType : boonItem.template.item_offering_info.keySet()) { @@ -271,8 +271,8 @@ public class Shrine extends AbstractWorldObject implements Comparable { } this.favors += amount; - boonOwner.getCharItemManager().delete(boonItem); - boonOwner.getCharItemManager().updateInventory(); + boonOwner.charItemManager.delete(boonItem); + boonOwner.charItemManager.updateInventory(); return true; } return false; diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 96598582..7ed3afcc 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -98,7 +98,7 @@ public class Warehouse { return; depositAmount = msg.getAmount(); - CharacterItemManager itemMan = player.getCharItemManager(); + CharacterItemManager itemMan = player.charItemManager; if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) return; @@ -250,7 +250,7 @@ public class Warehouse { if (warehouse.resources.get(resourceType) == null) return false; - CharacterItemManager itemMan = pc.getCharItemManager(); + CharacterItemManager itemMan = pc.charItemManager; if (itemMan == null) return false; @@ -465,7 +465,7 @@ public class Warehouse { if (amount <= 0) return false; - CharacterItemManager itemMan = pc.getCharItemManager(); + CharacterItemManager itemMan = pc.charItemManager; if (itemMan == null) return false; @@ -477,10 +477,10 @@ public class Warehouse { } if (addToInventory && resourceType.equals(Enum.ResourceType.GOLD)) { - if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount > MBServerStatics.PLAYER_GOLD_LIMIT) + if (pc.charItemManager.getGoldInventory().getNumOfItems() + amount > MBServerStatics.PLAYER_GOLD_LIMIT) return false; - if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount < 0) + if (pc.charItemManager.getGoldInventory().getNumOfItems() + amount < 0) return false; } int oldAmount = warehouse.resources.get(resourceType); @@ -551,7 +551,7 @@ public class Warehouse { if (amount <= 0) return false; - CharacterItemManager itemMan = pc.getCharItemManager(); + CharacterItemManager itemMan = pc.charItemManager; if (itemMan == null) return false; diff --git a/src/engine/powers/EffectsBase.java b/src/engine/powers/EffectsBase.java index 62b8ef48..57045b5c 100644 --- a/src/engine/powers/EffectsBase.java +++ b/src/engine/powers/EffectsBase.java @@ -451,8 +451,8 @@ public class EffectsBase { } if (awo.getObjectType().equals(GameObjectType.Item)) { - if (source.getCharItemManager() != null) { - source.getCharItemManager().updateInventory(); + if (source.charItemManager != null) { + source.charItemManager.updateInventory(); } } } diff --git a/src/engine/powers/poweractions/SetItemFlagPowerAction.java b/src/engine/powers/poweractions/SetItemFlagPowerAction.java index 3bd976a0..fba87b24 100644 --- a/src/engine/powers/poweractions/SetItemFlagPowerAction.java +++ b/src/engine/powers/poweractions/SetItemFlagPowerAction.java @@ -47,7 +47,7 @@ public class SetItemFlagPowerAction extends AbstractPowerAction { item.setIsID(false); //update failed, reset //update inventory - CharacterItemManager cim = source.getCharItemManager(); + CharacterItemManager cim = source.charItemManager; if (cim != null) cim.updateInventory(); } diff --git a/src/engine/powers/poweractions/StealPowerAction.java b/src/engine/powers/poweractions/StealPowerAction.java index ee1c41db..7fb5b14e 100644 --- a/src/engine/powers/poweractions/StealPowerAction.java +++ b/src/engine/powers/poweractions/StealPowerAction.java @@ -124,7 +124,7 @@ public class StealPowerAction extends AbstractPowerAction { return; //dupe check, validate player has item - if (!tar.validForInventory(ownerPC.getClientConnection(), ownerPC, ownerPC.getCharItemManager()))//pc.getCharItemManager())) + if (!tar.validForInventory(ownerPC.getClientConnection(), ownerPC, ownerPC.charItemManager))//pc.getCharItemManager())) return; //mark thief and target as player aggressive @@ -154,8 +154,8 @@ public class StealPowerAction extends AbstractPowerAction { } //attempt transfer item - CharacterItemManager myCIM = sourcePlayer.getCharItemManager(); - CharacterItemManager ownerCIM = ((AbstractCharacter) owner).getCharItemManager(); + CharacterItemManager myCIM = sourcePlayer.charItemManager; + CharacterItemManager ownerCIM = ((AbstractCharacter) owner).charItemManager; if (myCIM == null || ownerCIM == null) return; @@ -175,15 +175,15 @@ public class StealPowerAction extends AbstractPowerAction { DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); //update thief's inventory - if (sourcePlayer.getCharItemManager() != null) - sourcePlayer.getCharItemManager().updateInventory(); + if (sourcePlayer.charItemManager != null) + sourcePlayer.charItemManager.updateInventory(); //update victims inventory if (owner.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { PlayerCharacter ownerPC = (PlayerCharacter) owner; - if (ownerPC.getCharItemManager() != null) - ownerPC.getCharItemManager().updateInventory(); + if (ownerPC.charItemManager != null) + ownerPC.charItemManager.updateInventory(); } //TODO if victim is trading, cancel trade window for both people involved in trade diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index de1084a0..4043e974 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -559,8 +559,8 @@ public class WorldServer { return; //cancel any trade - if (playerCharacter.getCharItemManager() != null) - playerCharacter.getCharItemManager().endTrade(true); + if (playerCharacter.charItemManager != null) + playerCharacter.charItemManager.endTrade(true); // Release any mine claims