From df1b0e3f0f56d907ffb626a175e445068ee6901d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 May 2023 17:34:31 -0400 Subject: [PATCH] Refactor to remove abstraction. --- .../dbEffectsResourceCostHandler.java | 27 +++++++++++++++---- src/engine/objects/Item.java | 1 - 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/engine/db/handlers/dbEffectsResourceCostHandler.java b/src/engine/db/handlers/dbEffectsResourceCostHandler.java index cd86d0b6..36e58b35 100644 --- a/src/engine/db/handlers/dbEffectsResourceCostHandler.java +++ b/src/engine/db/handlers/dbEffectsResourceCostHandler.java @@ -9,8 +9,14 @@ package engine.db.handlers; +import engine.gameManager.DbManager; import engine.objects.EffectsResourceCosts; +import org.pmw.tinylog.Logger; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; public class dbEffectsResourceCostHandler extends dbHandlerBase { @@ -19,12 +25,23 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { this.localClass = EffectsResourceCosts.class; this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } - - public ArrayList GET_ALL_EFFECT_RESOURCES(String idString) { - prepareCallable("SELECT * FROM `static_power_effectcost` WHERE `IDString` = ?"); - setString(1, idString); - return getObjectList(); + + ArrayList effectsResourceCosts = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_power_effectcost` WHERE `IDString` = ?")) { + + preparedStatement.setString(1, idString); + + ResultSet rs = preparedStatement.executeQuery(); + effectsResourceCosts = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return effectsResourceCosts; } } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index ddabd85f..add14aa3 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -1062,7 +1062,6 @@ public float getBonusPercent(ModType modType, SourceType sourceType) { this.magicValue = this.getItemBase().getBaseValue() + calcMagicValue(); return; } - ConcurrentHashMap enchantList = DbManager.EnchantmentQueries.GET_ENCHANTMENTS_FOR_ITEM(this.getObjectUUID());