Browse Source

dex reductions

lakebane
FatBoy-DOTC 2 days ago
parent
commit
1568377725
  1. 34
      src/engine/db/handlers/dbItemBaseHandler.java

34
src/engine/db/handlers/dbItemBaseHandler.java

@ -22,6 +22,7 @@ import java.util.HashMap; @@ -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 { @@ -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 { @@ -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() {

Loading…
Cancel
Save