Browse Source

NPCManager class created.

master
MagicBot 2 years ago
parent
commit
33334ed13c
  1. 13
      src/engine/gameManager/NPCManager.java
  2. 7
      src/engine/objects/EquipmentSetEntry.java
  3. 3
      src/engine/objects/MobBase.java
  4. 2
      src/engine/objects/NPC.java

13
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<Integer, ArrayList<EquipmentSetEntry>> EquipmentSetMap = new HashMap<>();
}

7
src/engine/objects/EquipmentSetEntry.java

@ -10,19 +10,16 @@
package engine.objects; package engine.objects;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.NPCManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
public class EquipmentSetEntry { public class EquipmentSetEntry {
private float dropChance; private float dropChance;
private int itemID; private int itemID;
static HashMap<Integer, ArrayList<EquipmentSetEntry>> EquipmentSetMap = new HashMap<>();
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */
@ -33,7 +30,7 @@ public class EquipmentSetEntry {
} }
public static void LoadAllEquipmentSets() { 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() { float getDropChance() {

3
src/engine/objects/MobBase.java

@ -12,6 +12,7 @@ package engine.objects;
import ch.claude_martin.enumbitset.EnumBitSet; import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum; import engine.Enum;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.NPCManager;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -144,7 +145,7 @@ public class MobBase extends AbstractGameObject {
if (equipmentSetID == 0) if (equipmentSetID == 0)
return equip; return equip;
equipList = EquipmentSetEntry.EquipmentSetMap.get(equipmentSetID); equipList = NPCManager.EquipmentSetMap.get(equipmentSetID);
if (equipList == null) if (equipList == null)
return equip; return equip;

2
src/engine/objects/NPC.java

@ -1681,7 +1681,7 @@ public class NPC extends AbstractCharacter {
public static boolean UpdateEquipSetID(NPC npc, int equipSetID){ public static boolean UpdateEquipSetID(NPC npc, int equipSetID){
if (!EquipmentSetEntry.EquipmentSetMap.containsKey(equipSetID)) if (!NPCManager.EquipmentSetMap.containsKey(equipSetID))
return false; return false;
if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID)) if (!DbManager.NPCQueries.UPDATE_EQUIPSET(npc, equipSetID))

Loading…
Cancel
Save