diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 804b8587..bf12b434 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -10,7 +10,6 @@ package engine.db.handlers; import engine.gameManager.DbManager; -import engine.loot.BootySetEntry; import engine.objects.ItemBase; import org.pmw.tinylog.Logger; @@ -136,41 +135,4 @@ public class dbItemBaseHandler extends dbHandlerBase { return runeSets; } - public HashMap> LOAD_BOOTY_FOR_MOBS() { - - HashMap> bootySets = new HashMap<>(); - BootySetEntry bootySetEntry; - int bootySetID; - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { - - ResultSet rs = preparedStatement.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 { - ArrayList bootyList = bootySets.get(bootySetID); - bootyList.add(bootySetEntry); - bootySets.put(bootySetID, bootyList); - } - } - } catch (SQLException e) { - Logger.error(e); - return bootySets; - } - - Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); - return bootySets; - } } diff --git a/src/engine/db/handlers/dbLootTableHandler.java b/src/engine/db/handlers/dbLootHandler.java similarity index 83% rename from src/engine/db/handlers/dbLootTableHandler.java rename to src/engine/db/handlers/dbLootHandler.java index 40024d64..15b5289d 100644 --- a/src/engine/db/handlers/dbLootTableHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -11,10 +11,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; import engine.gameManager.LootManager; -import engine.loot.GenTableRow; -import engine.loot.ItemTableRow; -import engine.loot.ModTableRow; -import engine.loot.ModTypeTableRow; +import engine.loot.*; import engine.objects.Item; import engine.objects.LootTable; import org.pmw.tinylog.Logger; @@ -23,13 +20,53 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; -public class dbLootTableHandler extends dbHandlerBase { +public class dbLootHandler extends dbHandlerBase { - public dbLootTableHandler() { + public dbLootHandler() { } + public HashMap> LOAD_BOOTY_FOR_MOBS() { + + HashMap> bootySets = new HashMap<>(); + BootySetEntry bootySetEntry; + int bootySetID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) { + + ResultSet rs = preparedStatement.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 { + ArrayList bootyList = bootySets.get(bootySetID); + bootyList.add(bootySetEntry); + bootySets.put(bootySetID, bootyList); + } + } + } catch (SQLException e) { + Logger.error(e); + return bootySets; + } + + Logger.info("read: " + recordsRead + " cached: " + bootySets.size()); + return bootySets; + } + public void populateGenTables() { int recordsRead = 0; diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index a2e2522f..25792846 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -49,7 +49,7 @@ public enum DbManager { public static final dbItemHandler ItemQueries = new dbItemHandler(); public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler(); public static final dbKitHandler KitQueries = new dbKitHandler(); - public static final dbLootTableHandler LootQueries = new dbLootTableHandler(); + public static final dbLootHandler LootQueries = new dbLootHandler(); public static final dbMenuHandler MenuQueries = new dbMenuHandler(); public static final dbMineHandler MineQueries = new dbMineHandler(); public static final dbMobHandler MobQueries = new dbMobHandler(); diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 1e91ba5f..31e54704 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -25,7 +25,7 @@ public enum NPCManager { } public static void LoadAllBootySets() { - _bootySetMap = DbManager.ItemBaseQueries.LOAD_BOOTY_FOR_MOBS(); + _bootySetMap = DbManager.LootQueries.LOAD_BOOTY_FOR_MOBS(); } public static void applyRuneSetEffects(Mob mob) {