Browse Source

Pirate name related code moved to NPCmanager.

master
MagicBot 2 years ago
parent
commit
b8eb198b09
  1. 7
      src/engine/devcmd/cmds/AddNPCCmd.java
  2. 4
      src/engine/gameManager/BuildingManager.java
  3. 28
      src/engine/gameManager/NPCManager.java
  4. 2
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  5. 2
      src/engine/objects/Mob.java
  6. 28
      src/engine/objects/NPC.java
  7. 2
      src/engine/server/world/WorldServer.java

7
src/engine/devcmd/cmds/AddNPCCmd.java

@ -12,10 +12,7 @@ package engine.devcmd.cmds; @@ -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 { @@ -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());

4
src/engine/gameManager/BuildingManager.java

@ -471,7 +471,7 @@ public enum BuildingManager { @@ -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 { @@ -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;

28
src/engine/gameManager/NPCManager.java

@ -2,17 +2,16 @@ package engine.gameManager; @@ -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 { @@ -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<String> 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()));
}
}

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

@ -275,7 +275,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -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;

2
src/engine/objects/Mob.java

@ -752,7 +752,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -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();
}
}

28
src/engine/objects/NPC.java

@ -35,7 +35,6 @@ import java.util.ArrayList; @@ -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 { @@ -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<String> 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;

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

@ -382,7 +382,7 @@ public class WorldServer { @@ -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();

Loading…
Cancel
Save