Refactor out itembase

This commit is contained in:
2024-03-28 12:17:58 -04:00
parent 561b80b1aa
commit fc06ea97bd
5 changed files with 0 additions and 114 deletions
@@ -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());
}
}
-1
View File
@@ -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();
-55
View File
@@ -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<Integer, ItemBase> _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<Integer, ItemBase> getUUIDCache() {
return _itemBaseByUUID;
}
public static void loadAllItemBases() {
DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES();
}
public final int getUUID() {
return uuid;
}
}
-4
View File
@@ -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;
}
-3
View File
@@ -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();