diff --git a/src/engine/db/handlers/dbBoonHandler.java b/src/engine/db/handlers/dbBoonHandler.java deleted file mode 100644 index 3c16ca82..00000000 --- a/src/engine/db/handlers/dbBoonHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.db.handlers; - -import engine.gameManager.DbManager; -import engine.objects.Boon; -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 dbBoonHandler extends dbHandlerBase { - - public dbBoonHandler() { - } - - - public ArrayList GET_BOON_AMOUNTS_FOR_ITEMBASE(int itemBaseUUID) { - - ArrayList boons = new ArrayList<>(); - Boon thisBoon; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_boons` WHERE `itemBaseID` = ?")) { - - preparedStatement.setInt(1, itemBaseUUID); - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - thisBoon = new Boon(rs); - boons.add(thisBoon); - } - - } catch (SQLException e) { - Logger.error(e); - } - - return boons; - } -} diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index 97040017..8f4abdbd 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -69,7 +69,6 @@ public enum DbManager { public static final dbZoneHandler ZoneQueries = new dbZoneHandler(); public static final dbRealmHandler RealmQueries = new dbRealmHandler(); public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler(); - public static final dbBoonHandler BoonQueries = new dbBoonHandler(); public static final dbShrineHandler ShrineQueries = new dbShrineHandler(); public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler(); diff --git a/src/engine/objects/Boon.java b/src/engine/objects/Boon.java deleted file mode 100644 index 2cdcfd94..00000000 --- a/src/engine/objects/Boon.java +++ /dev/null @@ -1,59 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.Enum.ShrineType; -import engine.gameManager.DbManager; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; - - -public class Boon { - - public static HashMap> GetBoonsForItemBase = new HashMap<>(); - private ShrineType shrineType; - private int amount; - private int itemBaseID; - - - /** - * ResultSet Constructor - */ - public Boon(ResultSet rs) throws SQLException { - - this.shrineType = ShrineType.valueOf(rs.getString("shrineType")); - this.itemBaseID = rs.getInt("itemBaseID"); - this.amount = rs.getInt("amount"); - } - - public static void HandleBoonListsForItemBase(int itemBaseID) { - ArrayList boons = null; - boons = DbManager.BoonQueries.GET_BOON_AMOUNTS_FOR_ITEMBASE(itemBaseID); - if (boons != null) - GetBoonsForItemBase.put(itemBaseID, boons); - } - - public int getAmount() { - return this.amount; - } - - public int getItemBaseID() { - return itemBaseID; - } - - public ShrineType getShrineType() { - return shrineType; - } - - -} diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 166fbaa8..08fc5840 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -89,11 +89,8 @@ public class ItemBase { case BUCKET: case REALMCHARTER: case TREASURE: - this.isConsumable = true; - break; case OFFERING: this.isConsumable = true; - Boon.HandleBoonListsForItemBase(uuid); break; } diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 606ec008..0d3ba9eb 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -55,7 +55,7 @@ public class ItemTemplate { public String item_skill_mastery_used = ""; public int item_parry_anim_id; public float item_bulk_factor; - public HashMap item_offering_info = new HashMap<>(); + public HashMap item_offering_info = new HashMap<>(); public int item_defense_rating; public float item_weapon_wepspeed; public float item_weapon_max_range; @@ -186,7 +186,7 @@ public class ItemTemplate { JSONObject offering_entry = (JSONObject) entry; String offering_type = ((String) offering_entry.get("offering_type")).replaceAll("-", ""); int offering_value = ((Long) offering_entry.get("offering_value")).intValue(); - item_offering_info.put(offering_type, offering_value); + item_offering_info.put(Enum.ShrineType.valueOf(offering_type), offering_value); } // Fields only present for ARMOR diff --git a/src/engine/objects/Shrine.java b/src/engine/objects/Shrine.java index 928be579..ab3380d1 100644 --- a/src/engine/objects/Shrine.java +++ b/src/engine/objects/Shrine.java @@ -18,7 +18,6 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; public class Shrine extends AbstractWorldObject implements Comparable { @@ -254,28 +253,16 @@ public class Shrine extends AbstractWorldObject implements Comparable { if (boonItem == null) return false; - ItemBase ib = boonItem.getItemBase(); - - if (ib == null) - return false; - if (!boonOwner.getCharItemManager().doesCharOwnThisItem(boonItem.getObjectUUID())) return false; - ArrayList boonList = Boon.GetBoonsForItemBase.get(ib.getUUID()); - - if (boonList == null) - return false; - - for (Boon boon : boonList) { - - ShrineType boonShrineType = boon.getShrineType(); + for (ShrineType boonShrineType : boonItem.template.item_offering_info.keySet()) { if (boonShrineType != shrineType) continue; //Same Shrine Type, add favors and stop loop. - int amount = boon.getAmount() * boonItem.getNumOfItems(); + int amount = boonItem.template.item_offering_info.get(boonShrineType) * boonItem.getNumOfItems(); int oldAmount = this.favors; if (!DbManager.ShrineQueries.updateFavors(this, this.favors + amount, oldAmount)) {