diff --git a/src/engine/devcmd/cmds/AddNPCCmd.java b/src/engine/devcmd/cmds/AddNPCCmd.java index 7df268e7..a5bd5c87 100644 --- a/src/engine/devcmd/cmds/AddNPCCmd.java +++ b/src/engine/devcmd/cmds/AddNPCCmd.java @@ -12,10 +12,7 @@ package engine.devcmd.cmds; import engine.Enum.GameObjectType; import engine.InterestManagement.WorldGrid; import engine.devcmd.AbstractDevCmd; -import engine.gameManager.BuildingManager; -import engine.gameManager.ChatManager; -import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; +import engine.gameManager.*; import engine.objects.*; import org.pmw.tinylog.Logger; @@ -66,7 +63,7 @@ public class AddNPCCmd extends AbstractDevCmd { // Pick a random name if (name.isEmpty()) - name = NPC.getPirateName(contract.getMobbaseID()); + name = NPCManager.getPirateName(contract.getMobbaseID()); Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 9a3c79b4..ba4c106d 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -471,7 +471,7 @@ public enum BuildingManager { public static final synchronized boolean addHirelingForWorld(Building building, PlayerCharacter contractOwner, Vector3fImmutable NpcLoc, Zone zone, Contract NpcID, int rank) { - String pirateName = NPC.getPirateName(NpcID.getMobbaseID()); + String pirateName = NPCManager.getPirateName(NpcID.getMobbaseID()); NPC npc = null; @@ -497,7 +497,7 @@ public enum BuildingManager { if (building.getBlueprint().getMaxSlots() == building.getHirelings().size()) return false; - String pirateName = NPC.getPirateName(contract.getMobbaseID()); + String pirateName = NPCManager.getPirateName(contract.getMobbaseID()); if (item.getChargesRemaining() > 0) rank = item.getChargesRemaining() * 10; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index c949ed86..ea79c58f 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -2,17 +2,16 @@ package engine.gameManager; import engine.Enum; import engine.InterestManagement.WorldGrid; -import engine.math.Vector3fImmutable; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.objects.*; import engine.powers.EffectsBase; -import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.ThreadLocalRandom; public enum NPCManager { @@ -271,4 +270,29 @@ public enum NPCManager { WorldGrid.removeObject(mobile); return true; } + + public static void loadAllPirateNames() { + + DbManager.NPCQueries.LOAD_PIRATE_NAMES(); + } + + public static String getPirateName(int mobBaseID) { + + ArrayList nameList = null; + + // If we cannot find name for this mobbase then + // fallback to human male + + if (NPC._pirateNames.containsKey(mobBaseID)) + nameList = NPC._pirateNames.get(mobBaseID); + else + nameList = NPC._pirateNames.get(2111); + + if (nameList == null) { + Logger.error("Null name list for 2111!"); + } + + return nameList.get(ThreadLocalRandom.current().nextInt(nameList.size())); + + } } diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index 31966887..f5e059e1 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -275,7 +275,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { if (mobBase == 0) return true; - String pirateName = NPC.getPirateName(mobBase); + String pirateName = NPCManager.getPirateName(mobBase); if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) return true; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d8f1cad7..5c604226 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -752,7 +752,7 @@ public class Mob extends AbstractIntelligenceAgent { else rank = MBServerStatics.ELITE; - mob.firstName = NPC.getPirateName(mob.getMobBaseID()); + mob.firstName = NPCManager.getPirateName(mob.getMobBaseID()); mob.lastName = rank + " " + minionType.getRace() + " " + minionType.getName(); } } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 214cefc7..c8a7d4d2 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -35,7 +35,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.locks.ReentrantReadWriteLock; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; @@ -1264,33 +1263,6 @@ public class NPC extends AbstractCharacter { return true; } - public static void loadAllPirateNames() { - - DbManager.NPCQueries.LOAD_PIRATE_NAMES(); - } - - public static String getPirateName(int mobBaseID) { - - ArrayList nameList = null; - - // If we cannot find name for this mobbase then - // fallback to human male - - if (_pirateNames.containsKey(mobBaseID)) - nameList = _pirateNames.get(mobBaseID); - else - nameList = _pirateNames.get(2111); - - if (nameList == null) { - Logger.error("Null name list for 2111!"); - } - - return nameList.get(ThreadLocalRandom.current().nextInt(nameList.size())); - - } - - - public int getUpgradeCost() { int upgradeCost; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 05fefb00..7fd0217a 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -382,7 +382,7 @@ public class WorldServer { Runegate.loadAllRunegates(); Logger.info("Loading Pirate Names."); - NPC.loadAllPirateNames(); + NPCManager.loadAllPirateNames(); Logger.info("Loading Max Skills for Trainers"); DbManager.SkillsBaseQueries.LOAD_ALL_MAX_SKILLS_FOR_CONTRACT();