Browse Source

Remove old loader in preb for refactor

combat-2
MagicBot 9 months ago
parent
commit
e1e722f09f
  1. 39
      src/engine/db/handlers/dbItemBaseHandler.java
  2. 54
      src/engine/objects/ItemBase.java

39
src/engine/db/handlers/dbItemBaseHandler.java

@ -96,46 +96,7 @@ public class dbItemBaseHandler extends dbHandlerBase { @@ -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<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();

54
src/engine/objects/ItemBase.java

@ -20,6 +20,7 @@ import org.pmw.tinylog.Logger; @@ -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 { @@ -79,13 +80,12 @@ public class ItemBase {
private boolean autoID = false;
//requirements/restrictions
public ArrayList<Enum.MonsterType> restrictedRaces;
public ArrayList<Enum.MonsterType> requiredRaces;
public ArrayList<Enum.ClassType> restrictedClasses;
public ArrayList<Enum.ClassType> requiredClasses;
public ArrayList<Integer> requiredDiscs;
public ArrayList<Integer> restrictedDiscs;
public Enum.SexType requiredSex;
public EnumSet<Enum.MonsterType> restrictedRaces;
public EnumSet<Enum.MonsterType> requiredRaces;
public EnumSet<Enum.ClassType> restrictedClasses;
public EnumSet<Enum.ClassType> requiredClasses;
public EnumSet<Enum.DisciplineType> requiredDiscs;
public EnumSet<Enum.DisciplineType> restrictedDiscs;
/**
* ResultSet Constructor
@ -222,7 +222,7 @@ public class ItemBase { @@ -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 { @@ -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
}
}
}
}

Loading…
Cancel
Save