Browse Source

RuneSets generated loaded at bootstrap.

master
MagicBot 2 years ago
parent
commit
00d0048fd0
  1. 42
      src/engine/db/handlers/dbItemBaseHandler.java
  2. 9
      src/engine/gameManager/NPCManager.java
  3. 2
      src/engine/objects/MobBase.java
  4. 2
      src/engine/objects/NPC.java
  5. 3
      src/engine/server/world/WorldServer.java

42
src/engine/db/handlers/dbItemBaseHandler.java

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
package engine.db.handlers;
import engine.gameManager.NPCManager;
import engine.objects.EquipmentSetEntry;
import engine.objects.ItemBase;
import org.pmw.tinylog.Logger;
@ -149,4 +150,45 @@ public class dbItemBaseHandler extends dbHandlerBase { @@ -149,4 +150,45 @@ public class dbItemBaseHandler extends dbHandlerBase {
}
return equipmentSets;
}
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
int runeSetID;
int runeBaseID;
int recordsRead = 0;
prepareCallable("SELECT * FROM static_npc_runeSet");
try {
ResultSet rs = executeQuery();
while (rs.next()) {
recordsRead++;
runeSetID = rs.getInt("runeSet");
runeBaseID = rs.getInt("runeBase");
if (runeSets.get(runeSetID) == null){
ArrayList<Integer> runeList = new ArrayList<>();
runeList.add(runeBaseID);
runeSets.put(runeSetID, runeList);
}
else{
ArrayList<Integer>runeList = runeSets.get(runeSetID);
runeList.add(runeSetID);
runeSets.put(runeSetID, runeList);
}
}
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
} catch (SQLException e) {
Logger.error( e.toString());
} finally {
closeCallable();
}
return runeSets;
}
}

9
src/engine/gameManager/NPCManager.java

@ -7,10 +7,15 @@ import java.util.HashMap; @@ -7,10 +7,15 @@ import java.util.HashMap;
public enum NPCManager {
NPC_MANAGER;
public static HashMap<Integer, ArrayList<EquipmentSetEntry>> EquipmentSetMap = new HashMap<>();
public static HashMap<Integer, ArrayList<EquipmentSetEntry>> _equipmentSetMap = new HashMap<>();
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
public static void LoadAllEquipmentSets() {
EquipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
_equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
}
public static void LoadAllRuneSets() {
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
}
}

2
src/engine/objects/MobBase.java

@ -145,7 +145,7 @@ public class MobBase extends AbstractGameObject { @@ -145,7 +145,7 @@ public class MobBase extends AbstractGameObject {
if (equipmentSetID == 0)
return equip;
equipList = NPCManager.EquipmentSetMap.get(equipmentSetID);
equipList = NPCManager._equipmentSetMap.get(equipmentSetID);
if (equipList == null)
return equip;

2
src/engine/objects/NPC.java

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

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

@ -287,6 +287,9 @@ public class WorldServer { @@ -287,6 +287,9 @@ public class WorldServer {
Logger.info("Loading NPC and Mob Equipment Sets");
NPCManager.LoadAllEquipmentSets();
Logger.info("Loading NPC and Mob Rune Sets");
NPCManager.LoadAllRuneSets();
Logger.info("Loading Gold Loot for Mobbases");
MobbaseGoldEntry.LoadMobbaseGold();

Loading…
Cancel
Save