From fc06ea97bda8eb30842961f4ee1be3573578d030 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 28 Mar 2024 12:17:58 -0400 Subject: [PATCH] Refactor out itembase --- src/engine/db/handlers/dbItemBaseHandler.java | 51 ----------------- src/engine/gameManager/DbManager.java | 1 - src/engine/objects/ItemBase.java | 55 ------------------- src/engine/server/login/LoginServer.java | 4 -- src/engine/server/world/WorldServer.java | 3 - 5 files changed, 114 deletions(-) delete mode 100644 src/engine/db/handlers/dbItemBaseHandler.java delete mode 100644 src/engine/objects/ItemBase.java diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java deleted file mode 100644 index 762ed1f3..00000000 --- a/src/engine/db/handlers/dbItemBaseHandler.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.ItemBase; -import org.pmw.tinylog.Logger; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class dbItemBaseHandler extends dbHandlerBase { - - public dbItemBaseHandler() { - - } - - public void LOAD_ALL_ITEMBASES() { - - ItemBase itemBase; - int recordsRead = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itembase")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - recordsRead++; - itemBase = new ItemBase(rs); - - ItemBase.addToCache(itemBase); - } - - } catch (SQLException e) { - Logger.error(e); - } - - Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size()); - } - -} diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index 8f4abdbd..2d79b761 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -48,7 +48,6 @@ public enum DbManager { public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler(); public static final dbGuildHandler GuildQueries = new dbGuildHandler(); public static final dbItemHandler ItemQueries = new dbItemHandler(); - public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler(); public static final dbKitHandler KitQueries = new dbKitHandler(); public static final dbLootHandler LootQueries = new dbLootHandler(); public static final dbMenuHandler MenuQueries = new dbMenuHandler(); diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java deleted file mode 100644 index 3bd2485c..00000000 --- a/src/engine/objects/ItemBase.java +++ /dev/null @@ -1,55 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.gameManager.DbManager; -import org.pmw.tinylog.Logger; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.HashMap; - -public class ItemBase { - - public static ItemBase GOLD_ITEM_BASE = null; - public static HashMap _itemBaseByUUID = new HashMap<>(); - - public final int uuid; - - public ItemBase(ResultSet rs) throws SQLException { - - this.uuid = rs.getInt("ID"); - - } - - public static void addToCache(ItemBase itemBase) { - - _itemBaseByUUID.put(itemBase.uuid, itemBase); - - ItemTemplate template = ItemTemplate.templates.get(itemBase.uuid); - - if (template == null) - Logger.error("Null template for: " + itemBase.uuid); - } - - public static HashMap getUUIDCache() { - return _itemBaseByUUID; - } - - public static void loadAllItemBases() { - DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES(); - } - - - public final int getUUID() { - return uuid; - } - -} diff --git a/src/engine/server/login/LoginServer.java b/src/engine/server/login/LoginServer.java index b1ae150c..caed89c9 100644 --- a/src/engine/server/login/LoginServer.java +++ b/src/engine/server/login/LoginServer.java @@ -266,9 +266,6 @@ public class LoginServer { Logger.info("Loading Kits"); DbManager.KitQueries.GET_ALL_KITS(); - Logger.info("Initializing ItemBase data."); - ItemBase.loadAllItemBases(); - Logger.info("Initializing Race data"); Enum.RaceType.initRaceTypeTables(); Race.loadAllRaces(); @@ -279,7 +276,6 @@ public class LoginServer { Logger.info("Loading All Guilds"); DbManager.GuildQueries.GET_ALL_GUILDS(); - Logger.info("***Boot Successful***"); return true; } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index c5a11ddb..ffd9461d 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -346,9 +346,6 @@ public class WorldServer { Logger.info("Back fill template modTables"); DbManager.ItemQueries.LOAD_TEMPLATE_MODTABLES(); - Logger.info("Loading ItemBases"); - ItemBase.loadAllItemBases(); - Logger.info("Loading PromotionClasses"); DbManager.PromotionQueries.GET_ALL_PROMOTIONS();