forked from MagicBane/Server
BootySets generated with cache data loaded at bootstrap.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.NPCManager;
|
||||
import engine.objects.BootySetEntry;
|
||||
import engine.objects.EquipmentSetEntry;
|
||||
import engine.objects.ItemBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -191,4 +192,46 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
}
|
||||
return runeSets;
|
||||
}
|
||||
|
||||
public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_FOR_MOBS() {
|
||||
|
||||
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>();
|
||||
BootySetEntry bootySetEntry;
|
||||
int bootySetID;
|
||||
|
||||
int recordsRead = 0;
|
||||
|
||||
prepareCallable("SELECT * FROM static_npc_bootySet");
|
||||
|
||||
try {
|
||||
ResultSet rs = executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
recordsRead++;
|
||||
|
||||
bootySetID = rs.getInt("bootySet");
|
||||
bootySetEntry = new BootySetEntry(rs);
|
||||
|
||||
if (bootySets.get(bootySetID) == null){
|
||||
ArrayList<BootySetEntry> bootyList = new ArrayList<>();
|
||||
bootyList.add(bootySetEntry);
|
||||
bootySets.put(bootySetID, bootyList);
|
||||
}
|
||||
else{
|
||||
ArrayList<BootySetEntry>bootyList = bootySets.get(bootySetID);
|
||||
bootyList.add(bootySetEntry);
|
||||
bootySets.put(bootySetID, bootyList);
|
||||
}
|
||||
}
|
||||
|
||||
Logger.info("read: " + recordsRead + " cached: " + bootySets.size());
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error( e.toString());
|
||||
} finally {
|
||||
closeCallable();
|
||||
}
|
||||
return bootySets;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package engine.gameManager;
|
||||
|
||||
import engine.objects.BootySetEntry;
|
||||
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<>();
|
||||
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
||||
|
||||
public static HashMap<Integer, ArrayList<BootySetEntry>> _bootySetMap = new HashMap<>();
|
||||
|
||||
|
||||
public static void LoadAllEquipmentSets() {
|
||||
_equipmentSetMap = DbManager.ItemBaseQueries.LOAD_EQUIPMENT_FOR_NPC_AND_MOBS();
|
||||
@@ -18,4 +22,8 @@ public enum NPCManager {
|
||||
public static void LoadAllRuneSets() {
|
||||
_runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS();
|
||||
}
|
||||
|
||||
public static void LoadAllBootySets() {
|
||||
_bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class BootySetEntry {
|
||||
|
||||
public float dropChance;
|
||||
public int itemBase;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
|
||||
public BootySetEntry(ResultSet rs) throws SQLException {
|
||||
this.dropChance = (rs.getFloat("dropChance"));
|
||||
this.itemBase = (rs.getInt("itemBase"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -290,6 +290,9 @@ public class WorldServer {
|
||||
Logger.info("Loading NPC and Mob Rune Sets");
|
||||
NPCManager.LoadAllRuneSets();
|
||||
|
||||
Logger.info("Loading Mobile Booty Sets");
|
||||
NPCManager.LoadAllBootySets();
|
||||
|
||||
Logger.info("Loading Gold Loot for Mobbases");
|
||||
MobbaseGoldEntry.LoadMobbaseGold();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user