From 15683777251c533515eeb570b44a94292db721a1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 26 Jan 2025 19:28:59 -0600 Subject: [PATCH] dex reductions --- src/engine/db/handlers/dbItemBaseHandler.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index 2bada267..6b0e5bb0 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -22,6 +22,7 @@ import java.util.HashMap; public class dbItemBaseHandler extends dbHandlerBase { + public static final HashMap dexReductions = new HashMap<>(); public dbItemBaseHandler() { } @@ -46,20 +47,10 @@ public class dbItemBaseHandler extends dbHandlerBase { } public void LOAD_DEX_REDUCTION(ItemBase itemBase) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty` WHERE `ID` = ?")) { - - preparedStatement.setInt(1, itemBase.getUUID()); - ResultSet rs = preparedStatement.executeQuery(); - - // Check if a result was found - if (rs.next()) { - itemBase.dexReduction = rs.getFloat("item_bulk_factor"); - } - - } catch (SQLException e) { - Logger.error(e); + if(dexReductions.containsKey(itemBase.getUUID())){ + itemBase.dexReduction = dexReductions.get(itemBase.getUUID()); + }else{ + itemBase.dexReduction = 0.0f; } } @@ -112,6 +103,21 @@ public class dbItemBaseHandler extends dbHandlerBase { } Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size()); + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + // Check if a result was found + if (rs.next()) { + int ID = rs.getInt("ID"); + float factor = rs.getInt("item_bulk_factor"); + dexReductions.put(ID,factor); + } + + } catch (SQLException e) { + Logger.error(e); + } } public HashMap> LOAD_RUNES_FOR_NPC_AND_MOBS() {