From 33334ed13cae2e8200e033886b78a709b39e8048 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 28 Mar 2023 17:22:57 -0400 Subject: [PATCH] NPCManager class created. --- src/engine/gameManager/NPCManager.java | 13 +++++++++++++ src/engine/objects/EquipmentSetEntry.java | 7 ++----- src/engine/objects/MobBase.java | 3 ++- src/engine/objects/NPC.java | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/engine/gameManager/NPCManager.java diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java new file mode 100644 index 00000000..ef261daa --- /dev/null +++ b/src/engine/gameManager/NPCManager.java @@ -0,0 +1,13 @@ +package engine.gameManager; + +import engine.objects.EquipmentSetEntry; + +import java.util.ArrayList; +import java.util.HashMap; + +public enum NPCManager { + NPC_MANAGER; + public static HashMap> EquipmentSetMap = new HashMap<>(); + + +} diff --git a/src/engine/objects/EquipmentSetEntry.java b/src/engine/objects/EquipmentSetEntry.java index b3bdf8a6..7a6fbf49 100644 --- a/src/engine/objects/EquipmentSetEntry.java +++ b/src/engine/objects/EquipmentSetEntry.java @@ -10,19 +10,16 @@ package engine.objects; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; public class EquipmentSetEntry { private float dropChance; private int itemID; - static HashMap> EquipmentSetMap = new HashMap<>(); - /** * ResultSet Constructor */ @@ -33,7 +30,7 @@ public class EquipmentSetEntry { } public static void LoadAllEquipmentSets() { - EquipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); + NPCManager.EquipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS(); } float getDropChance() { diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index 2c4bf960..525e72af 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -12,6 +12,7 @@ package engine.objects; import ch.claude_martin.enumbitset.EnumBitSet; import engine.Enum; import engine.gameManager.DbManager; +import engine.gameManager.NPCManager; import engine.server.MBServerStatics; import java.sql.ResultSet; @@ -144,7 +145,7 @@ public class MobBase extends AbstractGameObject { if (equipmentSetID == 0) return equip; - equipList = EquipmentSetEntry.EquipmentSetMap.get(equipmentSetID); + equipList = NPCManager.EquipmentSetMap.get(equipmentSetID); if (equipList == null) return equip; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 2d2698fc..d1943d0d 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -1681,7 +1681,7 @@ public class NPC extends AbstractCharacter { public static boolean UpdateEquipSetID(NPC npc, int equipSetID){ - if (!EquipmentSetEntry.EquipmentSetMap.containsKey(equipSetID)) + if (!NPCManager.EquipmentSetMap.containsKey(equipSetID)) return false; if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))