diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 3da0c1c2..8f7cabec 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -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> LOAD_BOOTY_FOR_MOBS() { + + HashMap> 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 bootyList = new ArrayList<>(); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } + else{ + ArrayListbootyList = 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; + } } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 133c381a..4289fead 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -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> _equipmentSetMap = new HashMap<>(); public static HashMap> _runeSetMap = new HashMap<>(); + public static HashMap> _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(); + } } diff --git a/src/engine/objects/BootySetEntry.java b/src/engine/objects/BootySetEntry.java new file mode 100644 index 00000000..60aa0640 --- /dev/null +++ b/src/engine/objects/BootySetEntry.java @@ -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")); + } + +} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 3736b776..f08fde89 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -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();