From e1e722f09f8bac0ec78b5a24c936cab024d3af85 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 11 Feb 2024 07:29:42 -0500 Subject: [PATCH] Remove old loader in preb for refactor --- src/engine/db/handlers/dbItemBaseHandler.java | 39 -------------- src/engine/objects/ItemBase.java | 54 +++---------------- 2 files changed, 8 insertions(+), 85 deletions(-) diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index a190e230..e1b11523 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -96,46 +96,7 @@ public class dbItemBaseHandler extends dbHandlerBase { Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size()); } -public void LOAD_ALL_ITEM_REQUIREMENTS(){ - for(ItemBase itemBase : ItemBase._itemBaseByUUID.values()){ - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_item_requirements WHERE 'itemName' = ?")) { - preparedStatement.setString(1, itemBase.getName()); - ResultSet rs = preparedStatement.executeQuery(); - //while(rs.next()) { - - String racesRequired = ""; - if(rs.getString("racesRequired") != null) - racesRequired = rs.getString("racesRequired"); - - String racesRestricted = ""; - if(rs.getString("racesRestricted") != null) - racesRestricted = rs.getString("racesRestricted"); - - String classesRequired = ""; - if(rs.getString("classesRequired") != null) - classesRequired = rs.getString("classesRequired"); - - String classesRestricted = ""; - if(rs.getString("classesRestricted") != null) - classesRestricted = rs.getString("classesRestricted"); - - String discsRequired = ""; - if(rs.getString("discsRequired") != null) - discsRequired = rs.getString("discsRequired"); - - String discsRestricted = ""; - if(rs.getString("discsRestricted") != null) - discsRestricted = rs.getString("discsRestricted"); - - itemBase.LoadRequirements(racesRequired,racesRestricted,classesRequired, classesRestricted, discsRequired, discsRestricted); - //} - } catch (SQLException e) { - Logger.error("No Entry In static_item_requirements for item UUID: " + itemBase.getUUID()); - } - } -} public HashMap> LOAD_RUNES_FOR_NPC_AND_MOBS() { HashMap> runeSets = new HashMap<>(); diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index e9b15471..bca6e6da 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -20,6 +20,7 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; @@ -79,13 +80,12 @@ public class ItemBase { private boolean autoID = false; //requirements/restrictions - public ArrayList restrictedRaces; - public ArrayList requiredRaces; - public ArrayList restrictedClasses; - public ArrayList requiredClasses; - public ArrayList requiredDiscs; - public ArrayList restrictedDiscs; - public Enum.SexType requiredSex; + public EnumSet restrictedRaces; + public EnumSet requiredRaces; + public EnumSet restrictedClasses; + public EnumSet requiredClasses; + public EnumSet requiredDiscs; + public EnumSet restrictedDiscs; /** * ResultSet Constructor @@ -222,7 +222,7 @@ public class ItemBase { public static void loadAllItemBases() { DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES(); - DbManager.ItemBaseQueries.LOAD_ALL_ITEM_REQUIREMENTS(); + AnniverseryGifts.add(971000); AnniverseryGifts.add(971001); AnniverseryGifts.add(971002); @@ -979,42 +979,4 @@ public class ItemBase { return false; } - public void LoadRequirements(String racesRequired, String racesRestricted, String classesRequired, String classesRestricted, String discsRequired, String discsRestricted){ - this.requiredRaces = new ArrayList<>(); - this.restrictedRaces = new ArrayList<>(); - this.requiredClasses = new ArrayList<>(); - this.restrictedClasses = new ArrayList<>(); - this.requiredDiscs = new ArrayList<>(); - this.restrictedDiscs = new ArrayList<>(); - if(racesRequired != null){ - for(String entry : racesRequired.split(";")){ - requiredRaces.add(Enum.MonsterType.valueOf(entry)); - } - } - if(racesRestricted != null){ - for(String entry : racesRestricted.split(";")){ - restrictedRaces.add(Enum.MonsterType.valueOf(entry)); - } - } - if(classesRequired != null){ - for(String entry : classesRequired.split(";")){ - requiredClasses.add(Enum.ClassType.valueOf(entry)); - } - } - if(classesRestricted != null){ - for(String entry : classesRestricted.split(";")){ - restrictedClasses.add(Enum.ClassType.valueOf(entry)); - } - } - if(discsRequired != null){ - for(String entry : discsRequired.split(";")){ - //TODO find way to load disc runebaseID from name - } - } - if(discsRestricted != null){ - for(String entry : discsRestricted.split(";")) { - //TODO find way to load disc runebaseID from name - } - } - } }