From e93f84d1c78674e4c479f4fd083d6f4e99cc9c49 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 15 Mar 2024 10:58:01 -0400 Subject: [PATCH] Method moved out of itembase db handler --- src/engine/db/handlers/dbItemBaseHandler.java | 41 ------------------- src/engine/db/handlers/dbNPCHandler.java | 40 ++++++++++++++++++ src/engine/server/world/WorldServer.java | 3 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 52c8f8ae..762ed1f3 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -17,8 +17,6 @@ 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 dbItemBaseHandler extends dbHandlerBase { @@ -50,43 +48,4 @@ public class dbItemBaseHandler extends dbHandlerBase { Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size()); } - public HashMap> LOAD_RUNES_FOR_NPC_AND_MOBS() { - - HashMap> runeSets = new HashMap<>(); - int runeSetID; - int runeBaseID; - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - - recordsRead++; - - runeSetID = rs.getInt("runeSet"); - runeBaseID = rs.getInt("runeBase"); - - if (runeSets.get(runeSetID) == null) { - ArrayList runeList = new ArrayList<>(); - runeList.add(runeBaseID); - runeSets.put(runeSetID, runeList); - } else { - ArrayList runeList = runeSets.get(runeSetID); - runeList.add(runeSetID); - runeSets.put(runeSetID, runeList); - } - } - - } catch (SQLException e) { - Logger.error(e); - return runeSets; - } - - Logger.info("read: " + recordsRead + " cached: " + runeSets.size()); - return runeSets; - } - } diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 9887c6ed..c7cb706f 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -23,6 +23,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; public class dbNPCHandler extends dbHandlerBase { @@ -31,6 +32,45 @@ public class dbNPCHandler extends dbHandlerBase { this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public static HashMap> LOAD_RUNES_FOR_NPC_AND_MOBS() { + + HashMap> runeSets = new HashMap<>(); + int runeSetID; + int runeBaseID; + int recordsRead = 0; + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + recordsRead++; + + runeSetID = rs.getInt("runeSet"); + runeBaseID = rs.getInt("runeBase"); + + if (runeSets.get(runeSetID) == null) { + ArrayList runeList = new ArrayList<>(); + runeList.add(runeBaseID); + runeSets.put(runeSetID, runeList); + } else { + ArrayList runeList = runeSets.get(runeSetID); + runeList.add(runeSetID); + runeSets.put(runeSetID, runeList); + } + } + + } catch (SQLException e) { + Logger.error(e); + return runeSets; + } + + Logger.info("read: " + recordsRead + " cached: " + runeSets.size()); + return runeSets; + } + public NPC PERSIST(NPC toAdd) { NPC npc = null; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 25a178a9..8bd8427a 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -16,6 +16,7 @@ import engine.Enum.SupportMsgType; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; +import engine.db.handlers.dbNPCHandler; import engine.db.handlers.dbRuneBaseHandler; import engine.exception.MsgSendException; import engine.gameManager.*; @@ -349,7 +350,7 @@ public class WorldServer { DbManager.PromotionQueries.GET_ALL_PROMOTIONS(); Logger.info("Loading NPC and Mob Rune Sets"); - NPCManager._runeSetMap = DbManager.ItemBaseQueries.LOAD_RUNES_FOR_NPC_AND_MOBS(); + NPCManager._runeSetMap = dbNPCHandler.LOAD_RUNES_FOR_NPC_AND_MOBS(); Logger.info("Loading Booty Sets"); LootManager._bootySetMap = DbManager.LootQueries.LOAD_BOOTY_TABLES();