From fea1c2f06ab165df100025bea9638da18c2bfc24 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 4 Feb 2024 08:02:13 -0500 Subject: [PATCH] Raised visibility of collection --- src/engine/devcmd/cmds/InfoCmd.java | 6 ++--- src/engine/devcmd/cmds/PurgeObjectsCmd.java | 4 ++-- src/engine/devcmd/cmds/RemoveObjectCmd.java | 11 +++++---- src/engine/devcmd/cmds/SlotTestCmd.java | 6 ++--- src/engine/gameManager/BuildingManager.java | 24 +++++++++---------- src/engine/gameManager/NPCManager.java | 5 +--- .../handlers/ActivateNPCMsgHandler.java | 2 +- .../client/handlers/OrderNPCMsgHandler.java | 10 ++++---- .../net/client/msg/ManageCityAssetsMsg.java | 10 ++++---- src/engine/objects/Building.java | 8 ++----- src/engine/objects/City.java | 2 +- src/engine/objects/Mine.java | 7 ++++-- src/engine/objects/NPC.java | 2 +- 13 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index de86ac66..c023bec6 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -220,16 +220,16 @@ public class InfoCmd extends AbstractDevCmd { // List hirelings - if (targetBuilding.getHirelings().isEmpty() == false) { + if (targetBuilding.hirelings.isEmpty() == false) { output += newline; output += "Hirelings List: name / slot / floor"; - for (AbstractCharacter npc : targetBuilding.getHirelings().keySet()) { + for (AbstractCharacter npc : targetBuilding.hirelings.keySet()) { if (npc.getObjectType() != GameObjectType.NPC) continue; - output += newline + npc.getName() + " slot " + targetBuilding.getHirelings().get(npc); + output += newline + npc.getName() + " slot " + targetBuilding.hirelings.get(npc); output += newline + "location " + npc.getLoc(); } } diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index 23c5a1c8..53077bf0 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -48,7 +48,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { for (Building building : zone.zoneBuildingSet) { if (!BuildingManager.IsWallPiece(building)) continue; - for (AbstractCharacter ac : building.getHirelings().keySet()) { + for (AbstractCharacter ac : building.hirelings.keySet()) { NPC npc = null; Mob mobA = null; @@ -143,7 +143,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)) building.disableSpire(false); - for (AbstractCharacter ac : building.getHirelings().keySet()) { + for (AbstractCharacter ac : building.hirelings.keySet()) { NPC npc = null; Mob mobA = null; diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index 4221b06a..6f54a0b9 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -13,7 +13,10 @@ import engine.Enum.BuildingGroup; import engine.Enum.DbObjectType; import engine.InterestManagement.WorldGrid; import engine.devcmd.AbstractDevCmd; -import engine.gameManager.*; +import engine.gameManager.BuildingManager; +import engine.gameManager.ChatManager; +import engine.gameManager.DbManager; +import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.objects.*; @@ -141,7 +144,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { // Remove hirelings for this building - for (AbstractCharacter abstractCharacter : building.getHirelings().keySet()) + for (AbstractCharacter abstractCharacter : building.hirelings.keySet()) BuildingManager.removeHireling(building, abstractCharacter); Zone zone = building.getParentZone(); @@ -170,7 +173,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { // Remove npc from hirelings list. if (npc.building != null) - npc.building.getHirelings().remove(npc); + npc.building.hirelings.remove(npc); for (Integer minionUUID : npc.minions) { Mob minionMob = Mob.getMob(minionUUID); @@ -207,7 +210,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { // Remove npc from hirelings list. if (mob.building != null) - mob.building.getHirelings().remove(mob); + mob.building.hirelings.remove(mob); mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane.. mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc.. diff --git a/src/engine/devcmd/cmds/SlotTestCmd.java b/src/engine/devcmd/cmds/SlotTestCmd.java index bc31e7c2..347d603c 100644 --- a/src/engine/devcmd/cmds/SlotTestCmd.java +++ b/src/engine/devcmd/cmds/SlotTestCmd.java @@ -65,13 +65,13 @@ public class SlotTestCmd extends AbstractDevCmd { outString += "\r\nNext Available Slot: " + BuildingManager.getAvailableSlot(building); - if (building.getHirelings().isEmpty() == false) { + if (building.hirelings.isEmpty() == false) { outString += "\r\n\r\n"; outString += "Hirelings List:"; - for (AbstractCharacter hireling : building.getHirelings().keySet()) - outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling); + for (AbstractCharacter hireling : building.hirelings.keySet()) + outString += "\r\n" + hireling.getName() + " slot : " + building.hirelings.get(hireling); } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 70d94cd9..74e95ff7 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -58,7 +58,7 @@ public enum BuildingManager { for (int i = 1; i <= numOfSlots; i++) { - if (!building.getHirelings().containsValue(i)) + if (!building.hirelings.containsValue(i)) return i; } return -1; @@ -78,7 +78,7 @@ public enum BuildingManager { for (int i = numOfSlots; i > 0; i--) { - if (!building.getHirelings().containsValue(i)) + if (!building.hirelings.containsValue(i)) return i; } return -1; @@ -291,7 +291,7 @@ public enum BuildingManager { // Method transfers ownership of all hirelings in a building - public static void refreshHirelings(Building building) { + public static void updateHirelingGuilds(Building building) { if (building == null) return; @@ -303,7 +303,7 @@ public enum BuildingManager { else newGuild = building.getOwner().getGuild(); - for (AbstractCharacter hireling : building.getHirelings().keySet()) { + for (AbstractCharacter hireling : building.hirelings.keySet()) { hireling.setGuild(newGuild); WorldGrid.updateObject(hireling); } @@ -336,7 +336,7 @@ public enum BuildingManager { // Remove hireling from building - building.getHirelings().remove(hireling); + building.hirelings.remove(hireling); // Remove from zone mob set @@ -388,7 +388,7 @@ public enum BuildingManager { if (building.getRank() < 1) { - for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) + for (AbstractCharacter slottedNPC : building.hirelings.keySet()) BuildingManager.removeHireling(building, slottedNPC); return; @@ -396,14 +396,14 @@ public enum BuildingManager { // Delete hireling if building has deranked. - for (AbstractCharacter hireling : building.getHirelings().keySet()) { + for (AbstractCharacter hireling : building.hirelings.keySet()) { - if (building.getHirelings().get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank())) + if (building.hirelings.get(hireling) > building.getBlueprint().getSlotsForRank(building.getRank())) BuildingManager.removeHireling(building, hireling); } - refreshHirelings(building); + updateHirelingGuilds(building); } public static Building getBuilding(int id) { @@ -564,7 +564,7 @@ public enum BuildingManager { if (building.getBlueprintUUID() == 0) return false; - if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) + if (building.getBlueprint().getMaxSlots() == building.hirelings.size()) return false; String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); @@ -804,7 +804,7 @@ public enum BuildingManager { } - if (!building.getHirelings().containsKey(npc)) + if (!building.hirelings.containsKey(npc)) return; if (!npc.remove()) { @@ -812,7 +812,7 @@ public enum BuildingManager { return; } - building.getHirelings().remove(npc); + building.hirelings.remove(npc); itemBase = ItemBase.getItemBase(contract.getContractID()); diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 16395ad2..8d62b28f 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -5,17 +5,14 @@ import engine.InterestManagement.WorldGrid; import engine.math.Quaternion; import engine.math.Vector3f; import engine.math.Vector3fImmutable; -import engine.mobileAI.MobAI; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.objects.*; import engine.powers.EffectsBase; -import engine.powers.PowersBase; import engine.powers.RuneSkillAdjustEntry; import org.pmw.tinylog.Logger; -import javax.smartcardio.ATR; import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.ThreadLocalRandom; @@ -200,7 +197,7 @@ public enum NPCManager { // Pets are regular mobiles not hirelings (Siege engines) if (abstractCharacter.contract != null) - abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot); + abstractCharacter.building.hirelings.put(abstractCharacter, buildingSlot); // Override bind and location for this npc derived // from BuildingManager slot location data. diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index 0d2897bf..9d92278d 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -78,7 +78,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { return false; } - if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) + if (building.getBlueprint().getMaxSlots() == building.hirelings.size()) return false; Item contractItem = Item.getFromCache(msg.getContractItem()); diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index c7414459..2936dfac 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -54,7 +54,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { return; } - if (!building.getHirelings().containsKey(hireling)) + if (!building.hirelings.containsKey(hireling)) return; BuildingManager.removeHireling(building, hireling); @@ -402,7 +402,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (building == null) return true; - if (building.getHirelings().containsKey(npc) == false) + if (building.hirelings.containsKey(npc) == false) return true; @@ -421,7 +421,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false) return true; - if (building.getHirelings().containsKey(npc) == false) + if (building.hirelings.containsKey(npc) == false) return true; if (npc.remove() == false) { @@ -515,7 +515,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (building == null) return true; - if (!building.getHirelings().containsKey(mob)) + if (!building.hirelings.containsKey(mob)) return true; if (player.getCharItemManager().getTradingWith() != null) { @@ -531,7 +531,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (BuildingManager.playerCanManage(player, building) == false) return true; - if (building.getHirelings().containsKey(mob) == false) + if (building.hirelings.containsKey(mob) == false) return true; BuildingManager.removeHireling(building, mob); diff --git a/src/engine/net/client/msg/ManageCityAssetsMsg.java b/src/engine/net/client/msg/ManageCityAssetsMsg.java index 1c32d841..7d27e30c 100644 --- a/src/engine/net/client/msg/ManageCityAssetsMsg.java +++ b/src/engine/net/client/msg/ManageCityAssetsMsg.java @@ -229,8 +229,8 @@ public class ManageCityAssetsMsg extends ClientNetMsg { writer.putInt(asset.getObjectUUID()); writer.putInt(0); writer.putInt(0); - writer.putInt(asset.getHirelings().size()); - for (AbstractCharacter hireling : asset.getHirelings().keySet()) { + writer.putInt(asset.hirelings.size()); + for (AbstractCharacter hireling : asset.hirelings.keySet()) { if (!hireling.getObjectType().equals(GameObjectType.NPC)) writer.putString(hireling.getName()); else { @@ -262,9 +262,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg { for (int a = 0; a < 5; a++) writer.putInt(0); - writer.putInt(asset.getHirelings().size()); + writer.putInt(asset.hirelings.size()); - for (AbstractCharacter npcHire : asset.getHirelings().keySet()) { + for (AbstractCharacter npcHire : asset.hirelings.keySet()) { writer.putInt(npcHire.getObjectType().ordinal()); writer.putInt(npcHire.getObjectUUID()); if (npcHire.getObjectType() == GameObjectType.NPC) @@ -669,7 +669,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg { } - ConcurrentHashMap npcList = building.getHirelings(); + ConcurrentHashMap npcList = building.hirelings; writer.putInt(npcList.size()); if (npcList.size() > 0) { for (AbstractCharacter npcHire : npcList.keySet()) { diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 138d1ef5..6f322a23 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -51,7 +51,7 @@ public class Building extends AbstractWorldObject { // Used for thread safety private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - private final ConcurrentHashMap hirelings = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); + public final ConcurrentHashMap hirelings = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final HashMap doorJobs = new HashMap<>(); public int meshUUID; public Zone parentZone; @@ -1031,7 +1031,7 @@ public class Building extends AbstractWorldObject { // Set new guild for hirelings and refresh all clients this.refreshGuild(); - BuildingManager.refreshHirelings(this); + BuildingManager.updateHirelingGuilds(this); } catch (Exception e) { Logger.error("Error updating owner! UUID: " + this.getObjectUUID()); @@ -1213,10 +1213,6 @@ public class Building extends AbstractWorldObject { this.updateEffects(); } - public ConcurrentHashMap getHirelings() { - return hirelings; - } - public final boolean isSpireIsActive() { return spireIsActive; } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index d8c45c4d..fe654a0d 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -656,7 +656,7 @@ public class City extends AbstractWorldObject { if (this.getTOL() == null) return outNPC; - for (AbstractCharacter npc : getTOL().getHirelings().keySet()) { + for (AbstractCharacter npc : getTOL().hirelings.keySet()) { if (npc.getObjectType() == GameObjectType.NPC) if (((NPC) npc).getContract().isRuneMaster() == true) outNPC = (NPC) npc; diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 2dd2b4a1..b0274b4a 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -11,7 +11,10 @@ package engine.objects; import engine.Enum; import engine.InterestManagement.WorldGrid; -import engine.gameManager.*; +import engine.gameManager.BuildingManager; +import engine.gameManager.ChatManager; +import engine.gameManager.DbManager; +import engine.gameManager.ZoneManager; import engine.net.ByteBufferWriter; import engine.net.client.msg.ErrorPopupMsg; import engine.server.MBServerStatics; @@ -547,7 +550,7 @@ public class Mine extends AbstractGameObject { Building mineBuilding = BuildingManager.getBuilding(this.buildingID); if (mineBuilding == null) return this.production.baseProduction; - for (AbstractCharacter harvester : mineBuilding.getHirelings().keySet()) { + for (AbstractCharacter harvester : mineBuilding.hirelings.keySet()) { totalModded += baseModValue; totalModded += rankModValue * harvester.getRank(); } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index c54d5925..5e761d54 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1119,7 +1119,7 @@ public class NPC extends AbstractCharacter { building = this.building; if (building != null) { - building.getHirelings().remove(this); + building.hirelings.remove(this); this.removeMinions(); }