diff --git a/src/engine/db/handlers/dbLootHandler.java b/src/engine/db/handlers/dbLootHandler.java index 15b5289d..5f267701 100644 --- a/src/engine/db/handlers/dbLootHandler.java +++ b/src/engine/db/handlers/dbLootHandler.java @@ -29,7 +29,46 @@ public class dbLootHandler extends dbHandlerBase { } - public HashMap> LOAD_BOOTY_FOR_MOBS() { + public HashMap> LOAD_GEN_ITEM_TABLES() { + + HashMap> genTables = new HashMap<>(); + GenTableEntry genTableEntry; + + int genTableID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `genTable`, `minRoll`, `maxRoll`, `itemTableID`, `pModTableID`, `sModTableID` FROM `static_gentables`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + genTableID = rs.getInt("bootySet"); + genTableEntry = new GenTableEntry(rs); + + if (genTables.get(genTableID) == null) { + ArrayList genItemList = new ArrayList<>(); + genItemList.add(genTableEntry); + genTables.put(genTableID, genItemList); + } else { + ArrayList genItemList = genTables.get(genTableID); + genItemList.add(genTableEntry); + genTables.put(genTableID, genItemList); + } + } + } catch (SQLException e) { + Logger.error(e); + return genTables; + } + + Logger.info("read: " + recordsRead + " cached: " + genTables.size()); + return genTables; + } + + public HashMap> LOAD_BOOTY_TABLES() { HashMap> bootySets = new HashMap<>(); BootySetEntry bootySetEntry; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 31e54704..176e4278 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.LootQueries.LOAD_BOOTY_FOR_MOBS(); + _bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES(); } public static void applyRuneSetEffects(Mob mob) {