Browse Source

Start mobequip refactor

combat-2
MagicBot 8 months ago
parent
commit
61c4cb1361
  1. 20
      src/engine/db/handlers/dbContractHandler.java
  2. 10
      src/engine/devcmd/cmds/AddGoldCmd.java
  3. 2
      src/engine/devcmd/cmds/EnchantCmd.java
  4. 2
      src/engine/devcmd/cmds/InfoCmd.java
  5. 2
      src/engine/devcmd/cmds/MakeItemCmd.java
  6. 2
      src/engine/devcmd/cmds/PrintBankCmd.java
  7. 10
      src/engine/devcmd/cmds/PrintEquipCmd.java
  8. 2
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  9. 2
      src/engine/devcmd/cmds/PrintVaultCmd.java
  10. 136
      src/engine/devcmd/cmds/SetNpcEquipSetCmd.java
  11. 2
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  12. 4
      src/engine/gameManager/BuildingManager.java
  13. 1
      src/engine/gameManager/DevCmdManager.java
  14. 12
      src/engine/gameManager/FinalCombatManager.java
  15. 4
      src/engine/gameManager/GroupManager.java
  16. 20
      src/engine/gameManager/LootManager.java
  17. 2
      src/engine/gameManager/PowersManager.java
  18. 14
      src/engine/gameManager/TradeManager.java
  19. 2
      src/engine/mobileAI/MobAI.java
  20. 22
      src/engine/net/client/ClientMessagePump.java
  21. 4
      src/engine/net/client/handlers/ActivateNPCMsgHandler.java
  22. 6
      src/engine/net/client/handlers/BuyFromNPCMsgHandler.java
  23. 8
      src/engine/net/client/handlers/GuildCreationFinalizeHandler.java
  24. 28
      src/engine/net/client/handlers/ItemProductionMsgHandler.java
  25. 2
      src/engine/net/client/handlers/ObjectActionMsgHandler.java
  26. 8
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  27. 20
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  28. 6
      src/engine/net/client/handlers/RepairMsgHandler.java
  29. 7
      src/engine/net/client/handlers/TransferGoldToFromBuildingMsgHandler.java
  30. 7
      src/engine/net/client/handlers/TransferItemFromEquipToInventoryHandler.java
  31. 7
      src/engine/net/client/handlers/TransferItemFromInventoryToEquipHandler.java
  32. 4
      src/engine/net/client/msg/BuyFromNPCWindowMsg.java
  33. 2
      src/engine/net/client/msg/LootMsg.java
  34. 2
      src/engine/net/client/msg/RefineMsg.java
  35. 2
      src/engine/net/client/msg/ShowBankInventoryMsg.java
  36. 16
      src/engine/net/client/msg/TrainMsg.java
  37. 7
      src/engine/net/client/msg/UpdateGoldMsg.java
  38. 4
      src/engine/net/client/msg/UpdateTradeWindowMsg.java
  39. 4
      src/engine/net/client/msg/VendorDialogMsg.java
  40. 6
      src/engine/objects/AbstractCharacter.java
  41. 14
      src/engine/objects/Account.java
  42. 42
      src/engine/objects/CharacterItemManager.java
  43. 4
      src/engine/objects/Corpse.java
  44. 12
      src/engine/objects/Item.java
  45. 6
      src/engine/objects/ItemFactory.java
  46. 5
      src/engine/objects/MobBase.java
  47. 4
      src/engine/objects/MobLoot.java
  48. 19
      src/engine/objects/NPC.java
  49. 2
      src/engine/objects/PlayerCharacter.java
  50. 4
      src/engine/objects/Resists.java
  51. 6
      src/engine/objects/Shrine.java
  52. 12
      src/engine/objects/Warehouse.java
  53. 4
      src/engine/powers/EffectsBase.java
  54. 2
      src/engine/powers/poweractions/SetItemFlagPowerAction.java
  55. 14
      src/engine/powers/poweractions/StealPowerAction.java
  56. 4
      src/engine/server/world/WorldServer.java

20
src/engine/db/handlers/dbContractHandler.java

@ -65,27 +65,9 @@ public class dbContractHandler extends dbHandlerBase {
int templateID = rs.getInt("itembaseID"); 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); 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) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);

10
src/engine/devcmd/cmds/AddGoldCmd.java

@ -11,9 +11,7 @@ package engine.devcmd.cmds;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.ChatManager; import engine.gameManager.ChatManager;
import engine.objects.AbstractGameObject; import engine.objects.*;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
/** /**
* @author Eighty * @author Eighty
@ -32,7 +30,7 @@ public class AddGoldCmd extends AbstractDevCmd {
return; return;
} }
Item gold = pc.getCharItemManager().getGoldInventory(); Item gold = pc.charItemManager.getGoldInventory();
int curAmt; int curAmt;
if (gold == null) if (gold == null)
curAmt = 0; curAmt = 0;
@ -54,13 +52,13 @@ public class AddGoldCmd extends AbstractDevCmd {
return; return;
} }
if (!pc.getCharItemManager().addGoldToInventory(amt, true)) { if (!pc.charItemManager.addGoldToInventory(amt, true)) {
throwbackError(pc, "Failed to add gold to inventory"); throwbackError(pc, "Failed to add gold to inventory");
return; return;
} }
ChatManager.chatSayInfo(pc, amt + " gold added to inventory"); ChatManager.chatSayInfo(pc, amt + " gold added to inventory");
pc.getCharItemManager().updateInventory(); pc.charItemManager.updateInventory();
} }
@Override @Override

2
src/engine/devcmd/cmds/EnchantCmd.java

@ -43,7 +43,7 @@ public class EnchantCmd extends AbstractDevCmd {
return; return;
} }
CharacterItemManager cim = pc.getCharItemManager(); CharacterItemManager cim = pc.charItemManager;
if (cim == null) { if (cim == null) {
throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.'); throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.');
return; return;

2
src/engine/devcmd/cmds/InfoCmd.java

@ -278,7 +278,7 @@ public class InfoCmd extends AbstractDevCmd {
output += "Account ID: UNKNOWN"; output += "Account ID: UNKNOWN";
output += newline; output += newline;
output += "Inventory Weight:" + (targetPC.getCharItemManager().getInventoryWeight() + targetPC.getCharItemManager().getEquipWeight()); output += "Inventory Weight:" + (targetPC.charItemManager.getInventoryWeight() + targetPC.charItemManager.getEquipWeight());
output += newline; output += newline;
output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3); output += "Max Inventory Weight:" + ((int) targetPC.statStrBase * 3);
output += newline; output += newline;

2
src/engine/devcmd/cmds/MakeItemCmd.java

@ -144,7 +144,7 @@ public class MakeItemCmd extends AbstractDevCmd {
&& (template.item_type.equals(ItemType.OFFERING)) == false) && (template.item_type.equals(ItemType.OFFERING)) == false)
numItems = 1; numItems = 1;
CharacterItemManager cim = pc.getCharItemManager(); CharacterItemManager cim = pc.charItemManager;
if (cim == null) { if (cim == null) {
throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.'); throwbackError(pc, "Unable to find the character item manager for player " + pc.getFirstName() + '.');

2
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<Item> list = cim.getBank(); ArrayList<Item> list = cim.getBank();
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');

10
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -64,8 +64,8 @@ public class PrintEquipCmd extends AbstractDevCmd {
if (tar.getObjectType() == GameObjectType.Mob) { if (tar.getObjectType() == GameObjectType.Mob) {
Mob tarMob = (Mob) tar; Mob tarMob = (Mob) tar;
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) { for (Enum.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
Item equip = tarMob.getEquip().get(slot); Item equip = tarMob.charItemManager.equipped.get(slot);
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot); throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
} }
return; return;
@ -74,14 +74,14 @@ public class PrintEquipCmd extends AbstractDevCmd {
if (tar.getObjectType() == GameObjectType.NPC) { if (tar.getObjectType() == GameObjectType.NPC) {
NPC tarMob = (NPC) tar; NPC tarMob = (NPC) tar;
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Enum.EquipSlotType slot : tarMob.getEquip().keySet()) { for (Enum.EquipSlotType slot : tarMob.charItemManager.equipped.keySet()) {
Item equip = tarMob.getEquip().get(slot); Item equip = tarMob.charItemManager.equipped.get(slot);
throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot); throwbackInfo(pc, equip.templateID + " : " + equip.template.item_base_name + ", slot: " + slot);
} }
return; return;
} }
CharacterItemManager cim = ((AbstractCharacter) tar).getCharItemManager(); CharacterItemManager cim = ((AbstractCharacter) tar).charItemManager;
ConcurrentHashMap<Enum.EquipSlotType, Item> list = cim.getEquipped(); ConcurrentHashMap<Enum.EquipSlotType, Item> list = cim.getEquipped();
throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Equip for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');

2
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 inventory = cim.getInventory(); //this list can contain gold when tar is a PC that is dead
gold = cim.getGoldInventory(); gold = cim.getGoldInventory();
throwbackInfo(pc, " Weight : " + (cim.getInventoryWeight() + cim.getEquipWeight())); throwbackInfo(pc, " Weight : " + (cim.getInventoryWeight() + cim.getEquipWeight()));

2
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<Item> list = cim.getVault(); ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {

136
src/engine/devcmd/cmds/SetNpcEquipSetCmd.java

@ -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'";
}
}

2
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -56,7 +56,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
try { try {
mob.loadInventory(); mob.loadInventory();
for (Item lootItem : mob.getCharItemManager().getInventory()) { for (Item lootItem : mob.charItemManager.getInventory()) {
switch (lootItem.template.item_type) { switch (lootItem.template.item_type) {
case EMPLOYMENTCONTRACT: //CONTRACT case EMPLOYMENTCONTRACT: //CONTRACT
Contracts.add(lootItem); Contracts.add(lootItem);

4
src/engine/gameManager/BuildingManager.java

@ -209,7 +209,7 @@ public enum BuildingManager {
ItemTemplate template = ItemTemplate.templates.get(1705032); // Elan Stone ItemTemplate template = ItemTemplate.templates.get(1705032); // Elan Stone
if (!player.getCharItemManager().hasRoomInventory(template.item_wt)) if (!player.charItemManager.hasRoomInventory(template.item_wt))
return false; return false;
if (!Item.MakeItemForPlayer(template.template_id, player, amount)) if (!Item.MakeItemForPlayer(template.template_id, player, amount))
@ -231,7 +231,7 @@ public enum BuildingManager {
for (Enum.ResourceType resourceType : EnumSet.allOf(Enum.ResourceType.class)) { 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."); ChatManager.chatSystemInfo(player, "You can not carry any more of that item.");
return false; return false;
} }

1
src/engine/gameManager/DevCmdManager.java

@ -132,7 +132,6 @@ public enum DevCmdManager {
DevCmdManager.registerDevCmd(new GotoObj()); DevCmdManager.registerDevCmd(new GotoObj());
DevCmdManager.registerDevCmd(new convertLoc()); DevCmdManager.registerDevCmd(new convertLoc());
DevCmdManager.registerDevCmd(new UnloadFurnitureCmd()); DevCmdManager.registerDevCmd(new UnloadFurnitureCmd());
DevCmdManager.registerDevCmd(new SetNpcEquipSetCmd());
DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd()); DevCmdManager.registerDevCmd(new SetBuildingAltitudeCmd());
DevCmdManager.registerDevCmd(new ResetLevelCmd()); DevCmdManager.registerDevCmd(new ResetLevelCmd());
DevCmdManager.registerDevCmd(new SetNpcNameCmd()); DevCmdManager.registerDevCmd(new SetNpcNameCmd());

12
src/engine/gameManager/FinalCombatManager.java

@ -39,8 +39,8 @@ public class FinalCombatManager {
return; return;
} }
Item mainWeapon = attacker.getCharItemManager().getEquipped().get(Enum.EquipSlotType.RHELD); Item mainWeapon = attacker.charItemManager.getEquipped().get(Enum.EquipSlotType.RHELD);
Item offWeapon = attacker.getCharItemManager().getEquipped().get(Enum.EquipSlotType.LHELD); Item offWeapon = attacker.charItemManager.getEquipped().get(Enum.EquipSlotType.LHELD);
if(mainWeapon == null && offWeapon == null){ if(mainWeapon == null && offWeapon == null){
//no weapons equipped, punch with both fists //no weapons equipped, punch with both fists
processAttack(attacker,target,Enum.EquipSlotType.RHELD); processAttack(attacker,target,Enum.EquipSlotType.RHELD);
@ -71,7 +71,7 @@ public class FinalCombatManager {
PlayerBonuses bonus = attacker.getBonuses(); PlayerBonuses bonus = attacker.getBonuses();
float rangeMod = 1.0f; float rangeMod = 1.0f;
float attackRange = MBServerStatics.NO_WEAPON_RANGE; float attackRange = MBServerStatics.NO_WEAPON_RANGE;
Item weapon = attacker.getCharItemManager().getEquipped(slot); Item weapon = attacker.charItemManager.getEquipped(slot);
if (weapon != null) { if (weapon != null) {
if (bonus != null) if (bonus != null)
rangeMod += bonus.getFloatPercentAll(Enum.ModType.WeaponRange, Enum.SourceType.NONE); rangeMod += bonus.getFloatPercentAll(Enum.ModType.WeaponRange, Enum.SourceType.NONE);
@ -123,7 +123,7 @@ public class FinalCombatManager {
if (target.getObjectType() == Enum.GameObjectType.Building) if (target.getObjectType() == Enum.GameObjectType.Building)
hitChance = 100; 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) { if(ThreadLocalRandom.current().nextInt(100) > hitChance) {
TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim); TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim);
@ -161,13 +161,13 @@ public class FinalCombatManager {
//get the damage type //get the damage type
Enum.SourceType damageType; Enum.SourceType damageType;
if(attacker.getCharItemManager().getEquipped().get(slot) == null) { if(attacker.charItemManager.getEquipped().get(slot) == null) {
damageType = Enum.SourceType.CRUSHING; damageType = Enum.SourceType.CRUSHING;
if(attacker.getObjectType().equals(Enum.GameObjectType.Mob)) if(attacker.getObjectType().equals(Enum.GameObjectType.Mob))
if(((Mob)attacker).isSiege()) if(((Mob)attacker).isSiege())
damageType = Enum.SourceType.SIEGE; damageType = Enum.SourceType.SIEGE;
}else { }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 //get resists

4
src/engine/gameManager/GroupManager.java

@ -353,7 +353,7 @@ public enum GroupManager {
if (item.getObjectType() == Enum.GameObjectType.MobLoot) { if (item.getObjectType() == Enum.GameObjectType.MobLoot) {
if (tar.getObjectType() == Enum.GameObjectType.Mob) { if (tar.getObjectType() == Enum.GameObjectType.Mob) {
((Mob) tar).getCharItemManager().delete(item); ((Mob) tar).charItemManager.delete(item);
} else } else
item.setNumOfItems(0); item.setNumOfItems(0);
} else } else
@ -363,7 +363,7 @@ public enum GroupManager {
int amt = (group.isGroupLead(splitPlayer)) ? (amount + dif) : amount; int amt = (group.isGroupLead(splitPlayer)) ? (amount + dif) : amount;
if (amt > 0) if (amt > 0)
splitPlayer.getCharItemManager().addGoldToInventory(amt, false); splitPlayer.charItemManager.addGoldToInventory(amt, false);
} }
for (PlayerCharacter splitPlayer : playersSplit) { for (PlayerCharacter splitPlayer : playersSplit) {

20
src/engine/gameManager/LootManager.java

@ -310,7 +310,7 @@ public enum LootManager {
if (gold > 0) { if (gold > 0) {
MobLoot goldAmount = new MobLoot(mob, gold); 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); MobLoot toAdd = getGenTableItem(tableID, mob, inHotzone);
if (toAdd != null) if (toAdd != null)
mob.getCharItemManager().addItemToInventory(toAdd); mob.charItemManager.addItemToInventory(toAdd);
} catch (Exception e) { } catch (Exception e) {
//TODO chase down loot generation error, affects roughly 2% of drops //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 return; // safehold guards don't drop their equipment
//do equipment here //do equipment here
int dropCount = 0; int dropCount = 0;
if (mob.getEquip() != null) if (mob.charItemManager.equipped.isEmpty() == false)
for (Item me : mob.getEquip().values()) { for (Item item : mob.charItemManager.equipped.values()) {
if (me.getDropChance() == 0) if (item.drop_chance == 0)
continue; continue;
float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); float equipmentRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1);
float dropChance = me.getDropChance() * 100; float dropChance = item.drop_chance * 100;
if (equipmentRoll > dropChance) if (equipmentRoll > dropChance)
continue; continue;
MobLoot ml = new MobLoot(mob, me.template, false); MobLoot ml = new MobLoot(mob, item.template, false);
if (ml != null && dropCount < 1) { if (ml != null && dropCount < 1) {
ml.setIsID(true); ml.setIsID(true);
ml.setDurabilityCurrent((short) ((short) ml.durabilityCurrent - ThreadLocalRandom.current().nextInt(5) + 1)); ml.setDurabilityCurrent((short) ((short) ml.durabilityCurrent - ThreadLocalRandom.current().nextInt(5) + 1));
mob.getCharItemManager().addItemToInventory(ml); mob.charItemManager.addItemToInventory(ml);
dropCount = 1; dropCount = 1;
//break; // Exit on first successful roll. //break; // Exit on first successful roll.
} }
@ -372,7 +372,7 @@ public enum LootManager {
MobLoot lootItem = new MobLoot(mob, ItemTemplate.templates.get(bse.templateID), true); MobLoot lootItem = new MobLoot(mob, ItemTemplate.templates.get(bse.templateID), true);
if (lootItem != null) if (lootItem != null)
mob.getCharItemManager().addItemToInventory(lootItem); mob.charItemManager.addItemToInventory(lootItem);
} }
public static void peddleFate(PlayerCharacter playerCharacter, Item gift) { public static void peddleFate(PlayerCharacter playerCharacter, Item gift) {
@ -389,7 +389,7 @@ public enum LootManager {
//get the character item manager //get the character item manager
CharacterItemManager itemMan = playerCharacter.getCharItemManager(); CharacterItemManager itemMan = playerCharacter.charItemManager;
if (itemMan == null) if (itemMan == null)
return; return;

2
src/engine/gameManager/PowersManager.java

@ -1520,7 +1520,7 @@ public enum PowersManager {
if (owner.getObjectType().equals(GameObjectType.PlayerCharacter) || owner.getObjectType().equals(GameObjectType.Mob)) { if (owner.getObjectType().equals(GameObjectType.PlayerCharacter) || owner.getObjectType().equals(GameObjectType.Mob)) {
AbstractCharacter acOwner = (AbstractCharacter) owner; AbstractCharacter acOwner = (AbstractCharacter) owner;
CharacterItemManager itemMan = acOwner.getCharItemManager(); CharacterItemManager itemMan = acOwner.charItemManager;
if (itemMan == null) if (itemMan == null)
return true; return true;
if (itemMan.inventoryContains(item)) { if (itemMan.inventoryContains(item)) {

14
src/engine/gameManager/TradeManager.java

@ -28,7 +28,7 @@ public enum TradeManager {
if (source == null) if (source == null)
return; return;
source.getCharItemManager().tradeRequest(msg); source.charItemManager.tradeRequest(msg);
} }
@ -41,7 +41,7 @@ public enum TradeManager {
return; return;
try { try {
source.getCharItemManager().acceptTradeRequest(msg); source.charItemManager.acceptTradeRequest(msg);
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -60,7 +60,7 @@ public enum TradeManager {
if (source == null || !source.isAlive()) if (source == null || !source.isAlive())
return; return;
try { try {
source.getCharItemManager().addItemToTradeWindow(msg); source.charItemManager.addItemToTradeWindow(msg);
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
@ -76,7 +76,7 @@ public enum TradeManager {
return; return;
CharacterItemManager sourceItemMan = source.getCharItemManager(); CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null) if (sourceItemMan == null)
return; return;
@ -95,7 +95,7 @@ public enum TradeManager {
if (source == null || !source.isAlive()) if (source == null || !source.isAlive())
return; return;
CharacterItemManager sourceItemMan = source.getCharItemManager(); CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null) if (sourceItemMan == null)
return; return;
@ -115,7 +115,7 @@ public enum TradeManager {
if (source == null || !source.isAlive()) if (source == null || !source.isAlive())
return; return;
CharacterItemManager sourceItemMan = source.getCharItemManager(); CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null) if (sourceItemMan == null)
return; return;
@ -137,7 +137,7 @@ public enum TradeManager {
if (source == null) if (source == null)
return; return;
CharacterItemManager sourceItemMan = source.getCharItemManager(); CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null) if (sourceItemMan == null)
return; return;

2
src/engine/mobileAI/MobAI.java

@ -783,7 +783,7 @@ public class MobAI {
if (!aiAgent.despawned) { if (!aiAgent.despawned) {
if (aiAgent.getCharItemManager().getInventoryCount() > 0) { if (aiAgent.charItemManager.getInventoryCount() > 0) {
if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
aiAgent.despawn(); aiAgent.despawn();
aiAgent.deathTime = System.currentTimeMillis(); aiAgent.deathTime = System.currentTimeMillis();

22
src/engine/net/client/ClientMessagePump.java

@ -199,7 +199,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (!NPCVaultBankRangeCheck(player, origin, "bank")) if (!NPCVaultBankRangeCheck(player, origin, "bank"))
return; return;
CharacterItemManager itemManager = player.getCharItemManager(); CharacterItemManager itemManager = player.charItemManager;
if (itemManager == null) if (itemManager == null)
return; return;
@ -256,7 +256,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (!NPCVaultBankRangeCheck(player, origin, "bank")) if (!NPCVaultBankRangeCheck(player, origin, "bank"))
return; return;
CharacterItemManager itemManager = player.getCharItemManager(); CharacterItemManager itemManager = player.charItemManager;
if (itemManager == null) if (itemManager == null)
return; return;
@ -400,7 +400,7 @@ public class ClientMessagePump implements NetMsgHandler {
private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) { private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) {
CharacterItemManager itemManager = origin.getPlayerCharacter().getCharItemManager(); CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
int uuid = msg.getUUID(); int uuid = msg.getUUID();
@ -689,9 +689,9 @@ public class ClientMessagePump implements NetMsgHandler {
if (!GroupManager.goldSplit(player, item, origin, tar)) { 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 //Take equipment off mob
if (tar.getObjectType() == GameObjectType.Mob && itemRet != null) { if (tar.getObjectType() == GameObjectType.Mob && itemRet != null) {
@ -699,9 +699,9 @@ public class ClientMessagePump implements NetMsgHandler {
if (item != null && item.getObjectType() == GameObjectType.MobLoot) { 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); DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip); LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip);
@ -1037,7 +1037,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (player == null) if (player == null)
return; return;
CharacterItemManager itemMan = player.getCharItemManager(); CharacterItemManager itemMan = player.charItemManager;
if (itemMan == null) if (itemMan == null)
return; return;
@ -1058,14 +1058,14 @@ public class ClientMessagePump implements NetMsgHandler {
int cost = 0; int cost = 0;
if (npc.getCharItemManager().getInventoryCount() > 150) { if (npc.charItemManager.getInventoryCount() > 150) {
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID == 0) { if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID == 0) {
ArrayList<Item> inv = npc.getInventory(); ArrayList<Item> inv = npc.getInventory();
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
try { try {
Item toRemove = inv.get(i); Item toRemove = inv.get(i);
if (toRemove != null) if (toRemove != null)
npc.getCharItemManager().delete(toRemove); npc.charItemManager.delete(toRemove);
} catch (Exception e) { } catch (Exception e) {
break; break;
} }
@ -1091,7 +1091,7 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0) 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); ErrorPopupMsg.sendErrorPopup(player, 21);
return; return;

4
src/engine/net/client/handlers/ActivateNPCMsgHandler.java

@ -86,12 +86,12 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
if (contractItem == null) if (contractItem == null)
return false; 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!"); Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!");
return false; return false;
} }
itemMan = player.getCharItemManager(); itemMan = player.charItemManager;
zone = ZoneManager.findSmallestZone(building.getLoc()); zone = ZoneManager.findSmallestZone(building.getLoc());

6
src/engine/net/client/handlers/BuyFromNPCMsgHandler.java

@ -46,7 +46,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler {
if (origin.buyLock.tryLock()) { if (origin.buyLock.tryLock()) {
try { try {
CharacterItemManager itemMan = sourcePlayer.getCharItemManager(); CharacterItemManager itemMan = sourcePlayer.charItemManager;
if (itemMan == null) if (itemMan == null)
return true; return true;
@ -123,7 +123,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler {
} }
} else if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.Item.ordinal()) { } else if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.Item.ordinal()) {
CharacterItemManager npcCim = npc.getCharItemManager(); CharacterItemManager npcCim = npc.charItemManager;
if (npcCim == null) if (npcCim == null)
return true; return true;
@ -189,7 +189,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler {
} else if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.MobLoot.ordinal()) { } else if (buyFromNPCMsg.getItemType() == Enum.GameObjectType.MobLoot.ordinal()) {
CharacterItemManager npcCim = npc.getCharItemManager(); CharacterItemManager npcCim = npc.charItemManager;
if (npcCim == null) if (npcCim == null)
return true; return true;

8
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.ErrorPopupMsg;
import engine.net.client.msg.guild.GuildCreationFinalizeMsg; import engine.net.client.msg.guild.GuildCreationFinalizeMsg;
import engine.net.client.msg.guild.GuildInfoMsg; import engine.net.client.msg.guild.GuildInfoMsg;
import engine.objects.Guild; import engine.objects.*;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import engine.util.StringUtils; import engine.util.StringUtils;
public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
@ -131,8 +129,8 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
player.setInnerCouncil(true); player.setInnerCouncil(true);
player.setFullMember(true); player.setFullMember(true);
player.setGuildTitle(charterType.getNumberOfRanks() - 1); player.setGuildTitle(charterType.getNumberOfRanks() - 1);
player.getCharItemManager().delete(charter); player.charItemManager.delete(charter);
player.getCharItemManager().updateInventory(); player.charItemManager.updateInventory();
player.incVer(); player.incVer();
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2)); DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));

28
src/engine/net/client/handlers/ItemProductionMsgHandler.java

@ -129,18 +129,18 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem.template.item_type.equals(ItemType.GOLD)) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.template.item_wt)) { if (!vendor.charItemManager.hasRoomInventory(targetItem.template.item_wt)) {
ErrorPopupMsg.sendErrorPopup(player, 21); ErrorPopupMsg.sendErrorPopup(player, 21);
return; return;
} }
itemMan = origin.getPlayerCharacter().getCharItemManager(); itemMan = origin.getPlayerCharacter().charItemManager;
if (itemMan == null) if (itemMan == null)
return; return;
if (vendor.getCharItemManager().getInventoryWeight() > 500) { if (vendor.charItemManager.getInventoryWeight() > 500) {
ErrorPopupMsg.sendErrorPopup(player, 21); ErrorPopupMsg.sendErrorPopup(player, 21);
return; return;
} }
@ -166,7 +166,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
dispatch = Dispatch.borrow(player, outMsg); dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
origin.getPlayerCharacter().getCharItemManager().updateInventory(); origin.getPlayerCharacter().charItemManager.updateInventory();
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} finally { } finally {
@ -199,7 +199,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
return; return;
if (!vendor.getCharItemManager().forgeContains(targetItem, vendor)) if (!vendor.charItemManager.forgeContains(targetItem, vendor))
return; return;
boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem); boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem);
@ -213,7 +213,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
targetItem.containerType = Enum.ItemContainerType.INVENTORY; targetItem.containerType = Enum.ItemContainerType.INVENTORY;
targetItem.setOwner(vendor); targetItem.setOwner(vendor);
vendor.getCharItemManager().addItemToInventory(targetItem); vendor.charItemManager.addItemToInventory(targetItem);
vendor.removeItemFromForge(targetItem); vendor.removeItemFromForge(targetItem);
@ -269,9 +269,9 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem.template.item_type.equals(ItemType.GOLD)) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID())) if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID()))
continue; continue;
if (vendor.getCharItemManager().inventoryContains(targetItem) == false) if (vendor.charItemManager.inventoryContains(targetItem) == false)
continue; continue;
itemValue = targetItem.template.item_value; itemValue = targetItem.template.item_value;
@ -293,7 +293,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
} }
totalValue += itemValue; totalValue += itemValue;
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
vendor.getCharItemManager().recycle(targetItem); vendor.charItemManager.recycle(targetItem);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
long timetook = end - start; long timetook = end - start;
@ -347,7 +347,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
return; return;
if (!vendor.getCharItemManager().forgeContains(targetItem, vendor)) if (!vendor.charItemManager.forgeContains(targetItem, vendor))
return; return;
// Cannot junk items without a forge! // Cannot junk items without a forge!
@ -404,17 +404,17 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (targetItem.template.item_type.equals(ItemType.GOLD)) if (targetItem.template.item_type.equals(ItemType.GOLD))
return; return;
if (vendor.getCharItemManager().inventoryContains(targetItem) == false) if (vendor.charItemManager.inventoryContains(targetItem) == false)
return; return;
if (player.getCharItemManager().hasRoomInventory(targetItem.template.item_wt) == false) if (player.charItemManager.hasRoomInventory(targetItem.template.item_wt) == false)
return; return;
player.getCharItemManager().buyFromNPC(targetItem, vendor); player.charItemManager.buyFromNPC(targetItem, vendor);
} }
player.getCharItemManager().updateInventory(); player.charItemManager.updateInventory();
// Update NPC inventory to client // Update NPC inventory to client

2
src/engine/net/client/handlers/ObjectActionMsgHandler.java

@ -49,7 +49,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
return true; return true;
} }
itemMan = player.getCharItemManager(); itemMan = player.charItemManager;
if (itemMan == null) { if (itemMan == null) {
return true; return true;

8
src/engine/net/client/handlers/OrderNPCMsgHandler.java

@ -44,11 +44,11 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
Item item; Item item;
player = SessionManager.getPlayerCharacter(origin); player = SessionManager.getPlayerCharacter(origin);
itemMan = player.getCharItemManager(); itemMan = player.charItemManager;
contract = hireling.contract; contract = hireling.contract;
if (!player.getCharItemManager().hasRoomInventory((short) 1)) { if (!player.charItemManager.hasRoomInventory((short) 1)) {
ErrorPopupMsg.sendErrorPopup(player, 21); ErrorPopupMsg.sendErrorPopup(player, 21);
return; return;
} }
@ -400,7 +400,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
return true; return true;
if (player.getCharItemManager().getTradingWith() != null) { if (player.charItemManager.getTradingWith() != null) {
ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings."); ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings.");
return true; return true;
} }
@ -512,7 +512,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (!building.getHirelings().containsKey(mob)) if (!building.getHirelings().containsKey(mob))
return true; return true;
if (player.getCharItemManager().getTradingWith() != null) { if (player.charItemManager.getTradingWith() != null) {
ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings."); ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings.");
return true; return true;
} }

20
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -388,7 +388,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
case WAREHOUSE: case WAREHOUSE:
if (contract == null) if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID()))
break; break;
buildingCreated = placeWarehouse(playerCharacter, origin, msg); buildingCreated = placeWarehouse(playerCharacter, origin, msg);
break; break;
@ -396,28 +396,28 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
case BULWARK: case BULWARK:
if (contract == null) if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID()))
break; break;
buildingCreated = placeSiegeEquip(playerCharacter, origin, msg); buildingCreated = placeSiegeEquip(playerCharacter, origin, msg);
break; break;
case SPIRE: case SPIRE:
if (contract == null) if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID()))
break; break;
buildingCreated = placeSpire(playerCharacter, origin, msg); buildingCreated = placeSpire(playerCharacter, origin, msg);
break; break;
case SHRINE: case SHRINE:
if (contract == null) if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID()))
break; break;
buildingCreated = placeShrine(playerCharacter, origin, msg); buildingCreated = placeShrine(playerCharacter, origin, msg);
break; break;
case BARRACK: case BARRACK:
if (contract == null) if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID()))
break; break;
buildingCreated = placeBarrack(playerCharacter, origin, msg); buildingCreated = placeBarrack(playerCharacter, origin, msg);
break; break;
@ -433,7 +433,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
default: default:
if (contract == null) if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) if (!playerCharacter.charItemManager.doesCharOwnThisItem(contract.getObjectUUID()))
break; break;
buildingCreated = placeSingleBuilding(playerCharacter, origin, msg); buildingCreated = placeSingleBuilding(playerCharacter, origin, msg);
break; break;
@ -448,8 +448,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// Remove the appropriate deed. // Remove the appropriate deed.
if (buildingCreated == true) if (buildingCreated == true)
if (contract != null) { if (contract != null) {
playerCharacter.getCharItemManager().delete(contract); playerCharacter.charItemManager.delete(contract);
playerCharacter.getCharItemManager().updateInventory(); playerCharacter.charItemManager.updateInventory();
} }
// Close the window. We're done! // Close the window. We're done!
@ -1033,7 +1033,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
return false; return false;
if (player.getCharItemManager().getGoldTrading() > 0) { if (player.charItemManager.getGoldTrading() > 0) {
ErrorPopupMsg.sendErrorPopup(player, 195); ErrorPopupMsg.sendErrorPopup(player, 195);
return false; 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 // We need to be able to access how much gold a character is carrying
itemMan = player.getCharItemManager(); itemMan = player.charItemManager;
if (itemMan == null) if (itemMan == null)

6
src/engine/net/client/handlers/RepairMsgHandler.java

@ -60,7 +60,7 @@ public class RepairMsgHandler extends AbstractClientMsgHandler {
} else if (repairMsg.getMsgType() == 0) { //Request RepairObject } else if (repairMsg.getMsgType() == 0) { //Request RepairObject
CharacterItemManager itemMan = player.getCharItemManager(); CharacterItemManager itemMan = player.charItemManager;
if (itemMan == null) if (itemMan == null)
return true; return true;
@ -116,10 +116,10 @@ public class RepairMsgHandler extends AbstractClientMsgHandler {
return true; return true;
} }
if (player.getCharItemManager().getGoldInventory().getNumOfItems() - cost < 0) if (player.charItemManager.getGoldInventory().getNumOfItems() - cost < 0)
return true; return true;
if (player.getCharItemManager().getGoldInventory().getNumOfItems() - cost > MBServerStatics.PLAYER_GOLD_LIMIT) if (player.charItemManager.getGoldInventory().getNumOfItems() - cost > MBServerStatics.PLAYER_GOLD_LIMIT)
return true; return true;
if (!itemMan.buyFromNPC(building, cost, cost)) { if (!itemMan.buyFromNPC(building, cost, cost)) {

7
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.PlaceAssetMsg;
import engine.net.client.msg.TransferGoldToFromBuildingMsg; import engine.net.client.msg.TransferGoldToFromBuildingMsg;
import engine.net.client.msg.UpdateGoldMsg; import engine.net.client.msg.UpdateGoldMsg;
import engine.objects.Building; import engine.objects.*;
import engine.objects.CharacterItemManager;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import org.pmw.tinylog.Logger; 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); //building.getTimestamps().put(MBServerStatics.STRONGBOX_DELAY_STRING, System.currentTimeMillis() + MBServerStatics.ONE_MINUTE);
itemMan = player.getCharItemManager(); itemMan = player.charItemManager;
goldItem = itemMan.getGoldInventory(); goldItem = itemMan.getGoldInventory();

7
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.ApplyEffectMsg;
import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; import engine.net.client.msg.TransferItemFromEquipToInventoryMsg;
import engine.objects.CharacterItemManager; import engine.objects.*;
import engine.objects.Effect;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHandler { public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHandler {
@ -38,7 +35,7 @@ public class TransferItemFromEquipToInventoryHandler extends AbstractClientMsgHa
TransferItemFromEquipToInventoryMsg msg = (TransferItemFromEquipToInventoryMsg) baseMsg; TransferItemFromEquipToInventoryMsg msg = (TransferItemFromEquipToInventoryMsg) baseMsg;
CharacterItemManager itemManager = player.getCharItemManager(); CharacterItemManager itemManager = player.charItemManager;
if (itemManager == null) if (itemManager == null)
return true; return true;

7
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.ClientNetMsg;
import engine.net.client.msg.TransferItemFromEquipToInventoryMsg; import engine.net.client.msg.TransferItemFromEquipToInventoryMsg;
import engine.net.client.msg.TransferItemFromInventoryToEquipMsg; import engine.net.client.msg.TransferItemFromInventoryToEquipMsg;
import engine.objects.CharacterItemManager; import engine.objects.*;
import engine.objects.Effect;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHandler { public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHandler {
@ -36,7 +33,7 @@ public class TransferItemFromInventoryToEquipHandler extends AbstractClientMsgHa
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); PlayerCharacter playerCharacter = origin.getPlayerCharacter();
TransferItemFromInventoryToEquipMsg transferMsg = (TransferItemFromInventoryToEquipMsg) baseMsg; TransferItemFromInventoryToEquipMsg transferMsg = (TransferItemFromInventoryToEquipMsg) baseMsg;
CharacterItemManager itemManager = playerCharacter.getCharItemManager(); CharacterItemManager itemManager = playerCharacter.charItemManager;
if (itemManager == null) { if (itemManager == null) {
forceTransferFromEquipToInventory(transferMsg, origin, "Can't find your item manager"); forceTransferFromEquipToInventory(transferMsg, origin, "Can't find your item manager");

4
src/engine/net/client/msg/BuyFromNPCWindowMsg.java

@ -97,7 +97,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
ArrayList<Item> sellInventory = null; ArrayList<Item> sellInventory = null;
if (npc != null) { if (npc != null) {
man = npc.getCharItemManager(); man = npc.charItemManager;
Contract contract = npc.getContract(); Contract contract = npc.getContract();
if (player != null) { if (player != null) {
float barget = player.getBargain(); float barget = player.getBargain();
@ -149,7 +149,7 @@ public class BuyFromNPCWindowMsg extends ClientNetMsg {
for (Item Item : sellInventory) { for (Item Item : sellInventory) {
try { try {
Item.serializeForVendor(Item, writer, sellPercent); Item._serializeForVendor(Item, writer, sellPercent);
} catch (SerializationException se) { } catch (SerializationException se) {
continue; continue;
} }

2
src/engine/net/client/msg/LootMsg.java

@ -81,7 +81,7 @@ public class LootMsg extends ClientNetMsg {
else if (this.Item != null) else if (this.Item != null)
try { try {
Item._serializeForClientMsg(this.Item, writer, false); Item._serializeForClientMsg(this.Item, writer, false);
} catch (SerializationException e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }

2
src/engine/net/client/msg/RefineMsg.java

@ -82,7 +82,7 @@ public class RefineMsg extends ClientNetMsg {
//update player //update player
pc.applyBonuses(); pc.applyBonuses();
pc.getCharItemManager().RemoveEquipmentFromLackOfSkill(pc, true); pc.charItemManager.RemoveEquipmentFromLackOfSkill(pc, true);
//echo refine message back //echo refine message back

2
src/engine/net/client/msg/ShowBankInventoryMsg.java

@ -57,7 +57,7 @@ public class ShowBankInventoryMsg extends ClientNetMsg {
@Override @Override
protected void _serialize(ByteBufferWriter writer) throws SerializationException { protected void _serialize(ByteBufferWriter writer) throws SerializationException {
ArrayList<Item> bank = pc.getCharItemManager().getBank(); ArrayList<Item> bank = pc.charItemManager.getBank();
writer.put((byte) 1); // static value writer.put((byte) 1); // static value
Item.putList(writer, bank, false, pc.getObjectUUID()); Item.putList(writer, bank, false, pc.getObjectUUID());

16
src/engine/net/client/msg/TrainMsg.java

@ -72,12 +72,12 @@ public class TrainMsg extends ClientNetMsg {
if (origin.trainLock.tryLock()) { if (origin.trainLock.tryLock()) {
try { try {
Item gold = playerCharacter.getCharItemManager().getGoldInventory(); Item gold = playerCharacter.charItemManager.getGoldInventory();
if (gold == null) if (gold == null)
return; return;
if (!gold.validForInventory(origin, playerCharacter, playerCharacter.getCharItemManager())) if (!gold.validForInventory(origin, playerCharacter, playerCharacter.charItemManager))
return; return;
boolean canTrain = false; boolean canTrain = false;
@ -190,7 +190,7 @@ public class TrainMsg extends ClientNetMsg {
float profitCost = cost * npc.getSellPercent(playerCharacter); float profitCost = cost * npc.getSellPercent(playerCharacter);
profitCost += .5f; profitCost += .5f;
if (profitCost > playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems()) if (profitCost > playerCharacter.charItemManager.getGoldInventory().getNumOfItems())
return; return;
Building b = npc.getBuilding(); Building b = npc.getBuilding();
if (b != null && b.getProtectionState().equals(ProtectionState.NPC)) if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
@ -201,16 +201,16 @@ public class TrainMsg extends ClientNetMsg {
return; return;
} }
if (playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems() - profitCost < 0) if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() - profitCost < 0)
return; return;
if (playerCharacter.getCharItemManager().getGoldInventory().getNumOfItems() - profitCost > MBServerStatics.PLAYER_GOLD_LIMIT) if (playerCharacter.charItemManager.getGoldInventory().getNumOfItems() - profitCost > MBServerStatics.PLAYER_GOLD_LIMIT)
return; return;
//attempt to train //attempt to train
if (sk.train(playerCharacter)) { 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); dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
@ -253,7 +253,7 @@ public class TrainMsg extends ClientNetMsg {
float cost = (int) cp.getTrainingCost(playerCharacter, npc); float cost = (int) cp.getTrainingCost(playerCharacter, npc);
float profitCost = cost * npc.getSellPercent(playerCharacter); float profitCost = cost * npc.getSellPercent(playerCharacter);
profitCost += .5f; 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."); // ChatManager.chatSystemError(pc, "You do not have enough gold to train this skill.");
return; return;
} }
@ -269,7 +269,7 @@ public class TrainMsg extends ClientNetMsg {
} }
if (cp.train(playerCharacter)) { 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"); ChatManager.chatSystemError(playerCharacter, "Failed to Withdrawl gold from inventory. Contact CCR");
//train succeeded //train succeeded

7
src/engine/net/client/msg/UpdateGoldMsg.java

@ -15,10 +15,7 @@ import engine.net.AbstractConnection;
import engine.net.ByteBufferReader; import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import engine.net.client.Protocol; import engine.net.client.Protocol;
import engine.objects.AbstractWorldObject; import engine.objects.*;
import engine.objects.CharacterItemManager;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
/** /**
* Update gold in inventory and/or bank * Update gold in inventory and/or bank
@ -76,7 +73,7 @@ public class UpdateGoldMsg extends ClientNetMsg {
public void configure() { public void configure() {
if (this.looter != null && this.looter.getObjectType() == GameObjectType.PlayerCharacter) { if (this.looter != null && this.looter.getObjectType() == GameObjectType.PlayerCharacter) {
itemManager = ((PlayerCharacter) looter).getCharItemManager(); itemManager = ((PlayerCharacter) looter).charItemManager;
goldInventory = itemManager.getGoldInventory(); goldInventory = itemManager.getGoldInventory();
this.tradeGold = itemManager.getGoldTrading(); this.tradeGold = itemManager.getGoldTrading();
goldBank = itemManager.getGoldBank(); goldBank = itemManager.getGoldBank();

4
src/engine/net/client/msg/UpdateTradeWindowMsg.java

@ -63,7 +63,7 @@ public class UpdateTradeWindowMsg extends ClientNetMsg {
ArrayList<Item> trading1 = new ArrayList<>(); ArrayList<Item> trading1 = new ArrayList<>();
for (int itemID : pc1.getCharItemManager().getTrading()) { for (int itemID : pc1.charItemManager.getTrading()) {
Item item = Item.getFromCache(itemID); Item item = Item.getFromCache(itemID);
if (item == null) if (item == null)
continue; continue;
@ -71,7 +71,7 @@ public class UpdateTradeWindowMsg extends ClientNetMsg {
} }
ArrayList<Item> trading2 = new ArrayList<>(); ArrayList<Item> trading2 = new ArrayList<>();
for (int itemID : pc2.getCharItemManager().getTrading()) { for (int itemID : pc2.charItemManager.getTrading()) {
Item item = Item.getFromCache(itemID); Item item = Item.getFromCache(itemID);
if (item == null) if (item == null)
continue; continue;

4
src/engine/net/client/msg/VendorDialogMsg.java

@ -607,7 +607,7 @@ public class VendorDialogMsg extends ClientNetMsg {
if (ac == null) if (ac == null)
return; return;
CharacterItemManager itemManager = playerCharacter.getCharItemManager(); CharacterItemManager itemManager = playerCharacter.charItemManager;
if (itemManager == null) if (itemManager == null)
return; return;
@ -660,7 +660,7 @@ public class VendorDialogMsg extends ClientNetMsg {
if (cc == null) if (cc == null)
return; return;
CharacterItemManager itemManager = playerCharacter.getCharItemManager(); CharacterItemManager itemManager = playerCharacter.charItemManager;
if (itemManager == null) if (itemManager == null)
return; return;

6
src/engine/objects/AbstractCharacter.java

@ -49,7 +49,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
public abstract class AbstractCharacter extends AbstractWorldObject { public abstract class AbstractCharacter extends AbstractWorldObject {
protected CharacterItemManager charItemManager; public CharacterItemManager charItemManager;
private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock(); private final ReentrantReadWriteLock healthLock = new ReentrantReadWriteLock();
public short level; public short level;
public AbstractWorldObject combatTarget; public AbstractWorldObject combatTarget;
@ -657,10 +657,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
return this.unusedStatPoints; return this.unusedStatPoints;
} }
public final CharacterItemManager getCharItemManager() {
return this.charItemManager;
}
public final void setDebug( public final void setDebug(
final int value, final int value,
final boolean toggle final boolean toggle

14
src/engine/objects/Account.java

@ -214,16 +214,16 @@ public class Account extends AbstractGameObject {
} }
//dupe check //dupe check
if (!item.validForInventory(origin, player, player.getCharItemManager())) if (!item.validForInventory(origin, player, player.charItemManager))
return; return;
if (item.containerType == Enum.ItemContainerType.INVENTORY && player.getCharItemManager().isVaultOpen()) { if (item.containerType == Enum.ItemContainerType.INVENTORY && player.charItemManager.isVaultOpen()) {
if (!player.getCharItemManager().hasRoomVault(item.template.item_wt)) { if (!player.charItemManager.hasRoomVault(item.template.item_wt)) {
ClientMessagePump.forceTransferFromVaultToInventory(msg, origin, "There is no room in your vault."); ClientMessagePump.forceTransferFromVaultToInventory(msg, origin, "There is no room in your vault.");
return; return;
} }
if (player.getCharItemManager().moveItemToVault(item)) { if (player.charItemManager.moveItemToVault(item)) {
this.vault.add(item); this.vault.add(item);
dispatch = Dispatch.borrow(player, msg); dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
@ -245,7 +245,7 @@ public class Account extends AbstractGameObject {
return; return;
} }
CharacterItemManager itemManager = player.getCharItemManager(); CharacterItemManager itemManager = player.charItemManager;
if (itemManager == null) { if (itemManager == null) {
ClientMessagePump.forceTransferFromInventoryToVault(msg, origin, "Can't find your item manager."); ClientMessagePump.forceTransferFromInventoryToVault(msg, origin, "Can't find your item manager.");
@ -300,7 +300,7 @@ public class Account extends AbstractGameObject {
if (npc == null) if (npc == null)
return; return;
CharacterItemManager itemManager = player.getCharItemManager(); CharacterItemManager itemManager = player.charItemManager;
if (itemManager == null) if (itemManager == null)
return; return;
@ -347,7 +347,7 @@ public class Account extends AbstractGameObject {
if (!ClientMessagePump.NPCVaultBankRangeCheck(player, origin, "vault")) if (!ClientMessagePump.NPCVaultBankRangeCheck(player, origin, "vault"))
return; return;
CharacterItemManager itemManager = player.getCharItemManager(); CharacterItemManager itemManager = player.charItemManager;
if (itemManager == null) if (itemManager == null)
return; return;

42
src/engine/objects/CharacterItemManager.java

@ -94,12 +94,12 @@ public class CharacterItemManager {
if (template == null) if (template == null)
return; return;
CharacterItemManager itemMan = pc.getCharItemManager(); CharacterItemManager itemMan = pc.charItemManager;
if (itemMan == null) if (itemMan == null)
return; return;
CharacterItemManager npcCim = npc.getCharItemManager(); CharacterItemManager npcCim = npc.charItemManager;
if (npcCim == null) if (npcCim == null)
return; return;
@ -322,7 +322,7 @@ public class CharacterItemManager {
return false; return false;
} }
if (this.getOwner().getCharItemManager().getGoldTrading() > 0) { if (this.getOwner().charItemManager.getGoldTrading() > 0) {
if (this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) if (this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter))
ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195); ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195);
return false; return false;
@ -440,8 +440,8 @@ public class CharacterItemManager {
// TODO uncomment this block after we determine when we // TODO uncomment this block after we determine when we
// setBankOpen(false) and setVaultOpen(false) // setBankOpen(false) and setVaultOpen(false)
CharacterItemManager cim1 = source.getCharItemManager(); CharacterItemManager cim1 = source.charItemManager;
CharacterItemManager cim2 = target.getCharItemManager(); CharacterItemManager cim2 = target.charItemManager;
if (cim1 == null) if (cim1 == null)
return false; return false;
@ -539,7 +539,7 @@ public class CharacterItemManager {
return false; return false;
CharacterItemManager toTradeWith = target.getCharItemManager(); CharacterItemManager toTradeWith = target.charItemManager;
if (toTradeWith == null) if (toTradeWith == null)
return false; return false;
@ -603,7 +603,7 @@ public class CharacterItemManager {
if (other == null || !other.isAlive()) if (other == null || !other.isAlive())
return false; return false;
CharacterItemManager tradingWith = other.getCharItemManager(); CharacterItemManager tradingWith = other.charItemManager;
if (tradingWith == null) if (tradingWith == null)
return false; return false;
@ -669,7 +669,7 @@ public class CharacterItemManager {
if (other == null || !other.isAlive()) if (other == null || !other.isAlive())
return false; return false;
CharacterItemManager tradingWith = other.getCharItemManager(); CharacterItemManager tradingWith = other.charItemManager;
if (tradingWith == null) if (tradingWith == null)
return false; return false;
@ -725,7 +725,7 @@ public class CharacterItemManager {
if (source == null || !source.isAlive()) if (source == null || !source.isAlive())
return false; return false;
CharacterItemManager sourceItemMan = source.getCharItemManager(); CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null) if (sourceItemMan == null)
return false; return false;
@ -768,7 +768,7 @@ public class CharacterItemManager {
if (other == null || !other.isAlive()) if (other == null || !other.isAlive())
return false; return false;
CharacterItemManager tradingWith = other.getCharItemManager(); CharacterItemManager tradingWith = other.charItemManager;
if (tradingWith == null) if (tradingWith == null)
return false; return false;
@ -784,7 +784,7 @@ public class CharacterItemManager {
CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID); CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID);
this.commitTrade(); this.commitTrade();
this.closeTradeWindow(ctwm1, false); this.closeTradeWindow(ctwm1, false);
other.getCharItemManager().closeTradeWindow(ctwm2, false); other.charItemManager.closeTradeWindow(ctwm2, false);
} }
return true; return true;
} }
@ -797,7 +797,7 @@ public class CharacterItemManager {
if (this.getTradingWith().getPlayerCharacter() == null) if (this.getTradingWith().getPlayerCharacter() == null)
return false; return false;
CharacterItemManager man2 = this.getTradingWith().getPlayerCharacter().getCharItemManager(); CharacterItemManager man2 = this.getTradingWith().getPlayerCharacter().charItemManager;
Dispatch dispatch; Dispatch dispatch;
if (man1 == null || man2 == null) if (man1 == null || man2 == null)
@ -825,7 +825,7 @@ public class CharacterItemManager {
if (source == null) if (source == null)
return false; return false;
CharacterItemManager sourceItemMan = source.getCharItemManager(); CharacterItemManager sourceItemMan = source.charItemManager;
if (sourceItemMan == null) if (sourceItemMan == null)
return false; return false;
@ -851,7 +851,7 @@ public class CharacterItemManager {
sourceItemMan.endTrade(); sourceItemMan.endTrade();
cc2.getPlayerCharacter().getCharItemManager().closeTradeWindow(msg, false); cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false);
return true; return true;
@ -1149,7 +1149,7 @@ public class CharacterItemManager {
if (tar == null) if (tar == null)
return false; return false;
CharacterItemManager tarCim = tar.getCharItemManager(); CharacterItemManager tarCim = tar.charItemManager;
if (tarCim == null) if (tarCim == null)
return false; return false;
@ -1398,7 +1398,7 @@ public class CharacterItemManager {
return false; return false;
if (this.getOwner().getCharItemManager().getGoldTrading() > 0) { if (this.getOwner().charItemManager.getGoldTrading() > 0) {
if (this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) if (this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter))
ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195); ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195);
return false; return false;
@ -1437,7 +1437,7 @@ public class CharacterItemManager {
if (itemToSell == null || npc == null) if (itemToSell == null || npc == null)
return false; return false;
itemMan = npc.getCharItemManager(); itemMan = npc.charItemManager;
if (itemMan == null) if (itemMan == null)
return false; return false;
@ -1495,7 +1495,7 @@ public class CharacterItemManager {
if (purchasedItem == null || npc == null) if (purchasedItem == null || npc == null)
return false; return false;
itemMan = npc.getCharItemManager(); itemMan = npc.charItemManager;
if (itemMan == null) if (itemMan == null)
return false; return false;
@ -1587,7 +1587,7 @@ public class CharacterItemManager {
return null; return null;
// get looters item manager // get looters item manager
CharacterItemManager looterItems = lootingPlayer.getCharItemManager(); CharacterItemManager looterItems = lootingPlayer.charItemManager;
if (looterItems == null) if (looterItems == null)
return null; return null;
@ -2129,7 +2129,7 @@ public class CharacterItemManager {
tradeCharacter = this.tradingWith.getPlayerCharacter(); tradeCharacter = this.tradingWith.getPlayerCharacter();
tradeWeight = this.getCarriedWeight() + itemWeight; tradeWeight = this.getCarriedWeight() + itemWeight;
tradeWeight = tradeWeight + tradeCharacter.getCharItemManager().getTradingWeight(); tradeWeight = tradeWeight + tradeCharacter.charItemManager.getTradingWeight();
tradeWeight = tradeWeight - this.getTradingWeight(); tradeWeight = tradeWeight - this.getTradingWeight();
return tradeWeight <= (int) playerCharacter.statStrBase * 3; 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) if (tradingWith == null)
return false; return false;

4
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 //TODO transfer items from players inventory and trade window to corpse
CharacterItemManager cim = belongsTo.getCharItemManager(); CharacterItemManager cim = belongsTo.charItemManager;
if (cim != null) if (cim != null)
cim.transferEntireInventory(this.inventory, this, enterWorld); cim.transferEntireInventory(this.inventory, this, enterWorld);
else else
@ -287,7 +287,7 @@ public class Corpse extends AbstractWorldObject {
return null; return null;
//get looters item manager //get looters item manager
CharacterItemManager looterItems = looter.getCharItemManager(); CharacterItemManager looterItems = looter.charItemManager;
if (looterItems == null) if (looterItems == null)
return null; return null;

12
src/engine/objects/Item.java

@ -232,7 +232,7 @@ public class Item extends AbstractWorldObject {
if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) { if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter player = (PlayerCharacter) item.getOwner(); PlayerCharacter player = (PlayerCharacter) item.getOwner();
int tradingAmount = player.getCharItemManager().getGoldTrading(); int tradingAmount = player.charItemManager.getGoldTrading();
writer.putInt(item.numberOfItems - tradingAmount); writer.putInt(item.numberOfItems - tradingAmount);
} else } else
writer.putInt(item.numberOfItems); // Amount of gold writer.putInt(item.numberOfItems); // Amount of gold
@ -334,7 +334,7 @@ public class Item extends AbstractWorldObject {
writer.putInt(0); // Pad writer.putInt(0); // Pad
writer.putInt(player.getCharItemManager().getGoldTrading()); // Amount of gold writer.putInt(player.charItemManager.getGoldTrading()); // Amount of gold
writer.putInt(0); writer.putInt(0);
@ -347,7 +347,7 @@ public class Item extends AbstractWorldObject {
writer.putInt(4); //Non-Magical, grey name writer.putInt(4); //Non-Magical, grey name
writer.putInt(1); writer.putInt(1);
writer.putInt(0); // Pad writer.putInt(0); // Pad
writer.putInt(player.getCharItemManager().getGoldTrading()); writer.putInt(player.charItemManager.getGoldTrading());
writer.put((byte) 0); writer.put((byte) 0);
writer.putShort((short) 0); writer.putShort((short) 0);
@ -375,8 +375,8 @@ public class Item extends AbstractWorldObject {
if (!itemWorked) if (!itemWorked)
return false; return false;
reciever.getCharItemManager().addItemToInventory(item); reciever.charItemManager.addItemToInventory(item);
reciever.getCharItemManager().updateInventory(); reciever.charItemManager.updateInventory();
return true; return true;
} }
@ -515,7 +515,7 @@ public class Item extends AbstractWorldObject {
} }
++serialized; ++serialized;
} }
if (player.getCharItemManager().getGoldTrading() > 0) { if (player.charItemManager.getGoldTrading() > 0) {
Item.SerializeTradingGold(player, writer); Item.SerializeTradingGold(player, writer);
++serialized; ++serialized;
} }

6
src/engine/objects/ItemFactory.java

@ -36,7 +36,7 @@ public class ItemFactory {
return; return;
int max = 20; int max = 20;
CharacterItemManager itemManager = pc.getCharItemManager(); CharacterItemManager itemManager = pc.charItemManager;
ItemTemplate template = ItemTemplate.templates.get(templateID); ItemTemplate template = ItemTemplate.templates.get(templateID);
@ -96,7 +96,7 @@ public class ItemFactory {
if (forge == null) if (forge == null)
return null; return null;
if (!npc.getCharItemManager().hasRoomInventory(template.item_wt)) { if (!npc.charItemManager.hasRoomInventory(template.item_wt)) {
if (pc != null) if (pc != null)
ErrorPopupMsg.sendErrorPopup(pc, 21); ErrorPopupMsg.sendErrorPopup(pc, 21);
return null; return null;
@ -646,7 +646,7 @@ public class ItemFactory {
if (template == null) if (template == null)
return null; return null;
if (!vendor.getCharItemManager().hasRoomInventory(template.item_wt)) { if (!vendor.charItemManager.hasRoomInventory(template.item_wt)) {
if (playerCharacter != null) if (playerCharacter != null)
ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full."); ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full.");

5
src/engine/objects/MobBase.java

@ -127,9 +127,10 @@ public class MobBase extends AbstractGameObject {
for (BootySetEntry equipmentSetEntry : equipList) { for (BootySetEntry equipmentSetEntry : equipList) {
Item item = new Item(equipmentSetEntry.templateID); Item item = new Item(equipmentSetEntry.templateID);
item.objectUUID = MobLoot.lastNegativeID.decrementAndGet();
item.drop_chance = equipmentSetEntry.dropChance; item.drop_chance = equipmentSetEntry.dropChance;
item.equipSlot = item.template.item_eq_slots_or.iterator().next();
equip.put(item.slot, Item); equip.put(item.equipSlot, item);
} }

4
src/engine/objects/MobLoot.java

@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
public final class MobLoot extends Item { 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 isDeleted = false;
private boolean noSteal; private boolean noSteal;
@ -77,7 +77,7 @@ public final class MobLoot extends Item {
* @return Id number * @return Id number
*/ */
private static int generateId() { 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 //TODO Add a way to reclaim disposed IDs if this becomes a problem
if (id == (-10000)) if (id == (-10000))

19
src/engine/objects/NPC.java

@ -52,7 +52,6 @@ public class NPC extends AbstractCharacter {
private final ArrayList<MobLoot> rolling = new ArrayList<>(); private final ArrayList<MobLoot> rolling = new ArrayList<>();
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
public ArrayList<ProducedItem> forgedItems = new ArrayList<>(); public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
public HashMap<Enum.EquipSlotType, Item> equip = null;
public int runeSetID = 0; public int runeSetID = 0;
public int extraRune2 = 0; public int extraRune2 = 0;
protected int loadID; protected int loadID;
@ -341,11 +340,11 @@ public class NPC extends AbstractCharacter {
// get a copy of the equipped items. // get a copy of the equipped items.
if (npc.equip != null) { if (npc.charItemManager.equipped.isEmpty() == false) {
writer.putInt(npc.equip.size()); writer.putInt(npc.charItemManager.equipped.size());
for (Item me : npc.equip.values()) for (Item me : npc.charItemManager.equipped.values())
Item.serializeForClientMsg(me, writer); Item._serializeForClientMsg(me, writer);
} else } else
writer.putInt(0); writer.putInt(0);
@ -913,7 +912,7 @@ public class NPC extends AbstractCharacter {
if (equipmentSetID != 0 && LootManager._bootySetMap.get(equipmentSetID) == null) if (equipmentSetID != 0 && LootManager._bootySetMap.get(equipmentSetID) == null)
Logger.error("Invalid equipSet: " + equipmentSetID + " contract: " + this.contractUUID + " npc: " + this.getObjectUUID()); Logger.error("Invalid equipSet: " + equipmentSetID + " contract: " + this.contractUUID + " npc: " + this.getObjectUUID());
this.equip = loadEquipmentSet(this.equipmentSetID); this.charItemManager.equipped = loadEquipmentSet(this.equipmentSetID);
try { try {
@ -1241,7 +1240,7 @@ public class NPC extends AbstractCharacter {
if (targetItem == null) if (targetItem == null)
return false; return false;
if (!this.getCharItemManager().forgeContains(targetItem, this)) if (!this.charItemManager.forgeContains(targetItem, this))
return false; return false;
if (!DbManager.NPCQueries.UPDATE_ITEM_TO_INVENTORY(targetItem.getObjectUUID(), currentID)) if (!DbManager.NPCQueries.UPDATE_ITEM_TO_INVENTORY(targetItem.getObjectUUID(), currentID))
@ -1250,7 +1249,7 @@ public class NPC extends AbstractCharacter {
targetItem.setIsID(true); targetItem.setIsID(true);
this.rolling.remove(targetItem); this.rolling.remove(targetItem);
this.getCharItemManager().addItemToInventory(targetItem); this.charItemManager.addItemToInventory(targetItem);
//remove from client forge window //remove from client forge window
@ -1265,10 +1264,6 @@ public class NPC extends AbstractCharacter {
return true; return true;
} }
public HashMap<Enum.EquipSlotType, Item> getEquip() {
return equip;
}
public int getEquipmentSetID() { public int getEquipmentSetID() {
return equipmentSetID; return equipmentSetID;
} }

2
src/engine/objects/PlayerCharacter.java

@ -1944,7 +1944,7 @@ public class PlayerCharacter extends AbstractCharacter {
Mine.releaseMineClaims(this); Mine.releaseMineClaims(this);
this.getCharItemManager().closeTradeWindow(); this.charItemManager.closeTradeWindow();
//increment live counter. This is to prevent double kills from casts //increment live counter. This is to prevent double kills from casts
this.liveCounter++; this.liveCounter++;

4
src/engine/objects/Resists.java

@ -400,9 +400,9 @@ public class Resists {
// get resists from equipment // get resists from equipment
if (ac.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { 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}; float[] phys = {0f, 0f, 0f};
ConcurrentHashMap<Enum.EquipSlotType, Item> equip = ac.getCharItemManager().getEquipped(); ConcurrentHashMap<Enum.EquipSlotType, Item> equip = ac.charItemManager.getEquipped();
// get base physical resists // get base physical resists
phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.HELM), phys); phys = Resists.getArmorResists(equip.get(Enum.EquipSlotType.HELM), phys);

6
src/engine/objects/Shrine.java

@ -253,7 +253,7 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
if (boonItem == null) if (boonItem == null)
return false; return false;
if (!boonOwner.getCharItemManager().doesCharOwnThisItem(boonItem.getObjectUUID())) if (!boonOwner.charItemManager.doesCharOwnThisItem(boonItem.getObjectUUID()))
return false; return false;
for (ShrineType boonShrineType : boonItem.template.item_offering_info.keySet()) { for (ShrineType boonShrineType : boonItem.template.item_offering_info.keySet()) {
@ -271,8 +271,8 @@ public class Shrine extends AbstractWorldObject implements Comparable<Shrine> {
} }
this.favors += amount; this.favors += amount;
boonOwner.getCharItemManager().delete(boonItem); boonOwner.charItemManager.delete(boonItem);
boonOwner.getCharItemManager().updateInventory(); boonOwner.charItemManager.updateInventory();
return true; return true;
} }
return false; return false;

12
src/engine/objects/Warehouse.java

@ -98,7 +98,7 @@ public class Warehouse {
return; return;
depositAmount = msg.getAmount(); depositAmount = msg.getAmount();
CharacterItemManager itemMan = player.getCharItemManager(); CharacterItemManager itemMan = player.charItemManager;
if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID()))
return; return;
@ -250,7 +250,7 @@ public class Warehouse {
if (warehouse.resources.get(resourceType) == null) if (warehouse.resources.get(resourceType) == null)
return false; return false;
CharacterItemManager itemMan = pc.getCharItemManager(); CharacterItemManager itemMan = pc.charItemManager;
if (itemMan == null) if (itemMan == null)
return false; return false;
@ -465,7 +465,7 @@ public class Warehouse {
if (amount <= 0) if (amount <= 0)
return false; return false;
CharacterItemManager itemMan = pc.getCharItemManager(); CharacterItemManager itemMan = pc.charItemManager;
if (itemMan == null) if (itemMan == null)
return false; return false;
@ -477,10 +477,10 @@ public class Warehouse {
} }
if (addToInventory && resourceType.equals(Enum.ResourceType.GOLD)) { 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; return false;
if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount < 0) if (pc.charItemManager.getGoldInventory().getNumOfItems() + amount < 0)
return false; return false;
} }
int oldAmount = warehouse.resources.get(resourceType); int oldAmount = warehouse.resources.get(resourceType);
@ -551,7 +551,7 @@ public class Warehouse {
if (amount <= 0) if (amount <= 0)
return false; return false;
CharacterItemManager itemMan = pc.getCharItemManager(); CharacterItemManager itemMan = pc.charItemManager;
if (itemMan == null) if (itemMan == null)
return false; return false;

4
src/engine/powers/EffectsBase.java

@ -451,8 +451,8 @@ public class EffectsBase {
} }
if (awo.getObjectType().equals(GameObjectType.Item)) { if (awo.getObjectType().equals(GameObjectType.Item)) {
if (source.getCharItemManager() != null) { if (source.charItemManager != null) {
source.getCharItemManager().updateInventory(); source.charItemManager.updateInventory();
} }
} }
} }

2
src/engine/powers/poweractions/SetItemFlagPowerAction.java

@ -47,7 +47,7 @@ public class SetItemFlagPowerAction extends AbstractPowerAction {
item.setIsID(false); //update failed, reset item.setIsID(false); //update failed, reset
//update inventory //update inventory
CharacterItemManager cim = source.getCharItemManager(); CharacterItemManager cim = source.charItemManager;
if (cim != null) if (cim != null)
cim.updateInventory(); cim.updateInventory();
} }

14
src/engine/powers/poweractions/StealPowerAction.java

@ -124,7 +124,7 @@ public class StealPowerAction extends AbstractPowerAction {
return; return;
//dupe check, validate player has item //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; return;
//mark thief and target as player aggressive //mark thief and target as player aggressive
@ -154,8 +154,8 @@ public class StealPowerAction extends AbstractPowerAction {
} }
//attempt transfer item //attempt transfer item
CharacterItemManager myCIM = sourcePlayer.getCharItemManager(); CharacterItemManager myCIM = sourcePlayer.charItemManager;
CharacterItemManager ownerCIM = ((AbstractCharacter) owner).getCharItemManager(); CharacterItemManager ownerCIM = ((AbstractCharacter) owner).charItemManager;
if (myCIM == null || ownerCIM == null) if (myCIM == null || ownerCIM == null)
return; return;
@ -175,15 +175,15 @@ public class StealPowerAction extends AbstractPowerAction {
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
//update thief's inventory //update thief's inventory
if (sourcePlayer.getCharItemManager() != null) if (sourcePlayer.charItemManager != null)
sourcePlayer.getCharItemManager().updateInventory(); sourcePlayer.charItemManager.updateInventory();
//update victims inventory //update victims inventory
if (owner.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { if (owner.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
PlayerCharacter ownerPC = (PlayerCharacter) owner; PlayerCharacter ownerPC = (PlayerCharacter) owner;
if (ownerPC.getCharItemManager() != null) if (ownerPC.charItemManager != null)
ownerPC.getCharItemManager().updateInventory(); ownerPC.charItemManager.updateInventory();
} }
//TODO if victim is trading, cancel trade window for both people involved in trade //TODO if victim is trading, cancel trade window for both people involved in trade

4
src/engine/server/world/WorldServer.java

@ -559,8 +559,8 @@ public class WorldServer {
return; return;
//cancel any trade //cancel any trade
if (playerCharacter.getCharItemManager() != null) if (playerCharacter.charItemManager != null)
playerCharacter.getCharItemManager().endTrade(true); playerCharacter.charItemManager.endTrade(true);
// Release any mine claims // Release any mine claims

Loading…
Cancel
Save