dex reductions

This commit is contained in:
2025-01-26 19:28:59 -06:00
parent 7b32cfe235
commit 1568377725
+20 -14
View File
@@ -22,6 +22,7 @@ import java.util.HashMap;
public class dbItemBaseHandler extends dbHandlerBase {
public static final HashMap<Integer,Float> 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<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {