forked from MagicBane/Server
Refactor out itembase
This commit is contained in:
@@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -48,7 +48,6 @@ public enum DbManager {
|
|||||||
public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler();
|
public static final dbEffectsResourceCostHandler EffectsResourceCostsQueries = new dbEffectsResourceCostHandler();
|
||||||
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
|
public static final dbGuildHandler GuildQueries = new dbGuildHandler();
|
||||||
public static final dbItemHandler ItemQueries = new dbItemHandler();
|
public static final dbItemHandler ItemQueries = new dbItemHandler();
|
||||||
public static final dbItemBaseHandler ItemBaseQueries = new dbItemBaseHandler();
|
|
||||||
public static final dbKitHandler KitQueries = new dbKitHandler();
|
public static final dbKitHandler KitQueries = new dbKitHandler();
|
||||||
public static final dbLootHandler LootQueries = new dbLootHandler();
|
public static final dbLootHandler LootQueries = new dbLootHandler();
|
||||||
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
|
public static final dbMenuHandler MenuQueries = new dbMenuHandler();
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -266,9 +266,6 @@ public class LoginServer {
|
|||||||
Logger.info("Loading Kits");
|
Logger.info("Loading Kits");
|
||||||
DbManager.KitQueries.GET_ALL_KITS();
|
DbManager.KitQueries.GET_ALL_KITS();
|
||||||
|
|
||||||
Logger.info("Initializing ItemBase data.");
|
|
||||||
ItemBase.loadAllItemBases();
|
|
||||||
|
|
||||||
Logger.info("Initializing Race data");
|
Logger.info("Initializing Race data");
|
||||||
Enum.RaceType.initRaceTypeTables();
|
Enum.RaceType.initRaceTypeTables();
|
||||||
Race.loadAllRaces();
|
Race.loadAllRaces();
|
||||||
@@ -279,7 +276,6 @@ public class LoginServer {
|
|||||||
Logger.info("Loading All Guilds");
|
Logger.info("Loading All Guilds");
|
||||||
DbManager.GuildQueries.GET_ALL_GUILDS();
|
DbManager.GuildQueries.GET_ALL_GUILDS();
|
||||||
|
|
||||||
|
|
||||||
Logger.info("***Boot Successful***");
|
Logger.info("***Boot Successful***");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,9 +346,6 @@ public class WorldServer {
|
|||||||
Logger.info("Back fill template modTables");
|
Logger.info("Back fill template modTables");
|
||||||
DbManager.ItemQueries.LOAD_TEMPLATE_MODTABLES();
|
DbManager.ItemQueries.LOAD_TEMPLATE_MODTABLES();
|
||||||
|
|
||||||
Logger.info("Loading ItemBases");
|
|
||||||
ItemBase.loadAllItemBases();
|
|
||||||
|
|
||||||
Logger.info("Loading PromotionClasses");
|
Logger.info("Loading PromotionClasses");
|
||||||
DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
|
DbManager.PromotionQueries.GET_ALL_PROMOTIONS();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user