forked from MagicBane/Server
Loading effect costmap data at bootsrap
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.gameManager.PowersManager;
|
||||||
import engine.mbEnums;
|
import engine.mbEnums;
|
||||||
import engine.objects.EffectsResourceCosts;
|
import engine.objects.EffectsResourceCosts;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -96,6 +97,32 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LOAD_ALL_COSTMAPS() {
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_effect_costmaps`")) {
|
||||||
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
String effectID = rs.getString("effectID");
|
||||||
|
String costString = rs.getString("costmap");
|
||||||
|
JSONObject costJSON = new JSONObject(costString);
|
||||||
|
HashMap<mbEnums.ResourceType, Integer> costmap = new HashMap<>();
|
||||||
|
|
||||||
|
for (String key : costJSON.keySet()) {
|
||||||
|
int value = costJSON.getInt(key);
|
||||||
|
costmap.put(mbEnums.ResourceType.valueOf(key), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
PowersManager._effect_costMaps.put(effectID, costmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<EffectsResourceCosts> GET_ALL_EFFECT_RESOURCES(String idString) {
|
public ArrayList<EffectsResourceCosts> GET_ALL_EFFECT_RESOURCES(String idString) {
|
||||||
|
|
||||||
ArrayList<EffectsResourceCosts> effectsResourceCosts = new ArrayList<>();
|
ArrayList<EffectsResourceCosts> effectsResourceCosts = new ArrayList<>();
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public enum PowersManager {
|
|||||||
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
||||||
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
|
public static HashMap<Integer, ArrayList<RunePowerEntry>> _allRunePowers;
|
||||||
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> _allRuneSkillAdjusts;
|
public static HashMap<Integer, ArrayList<RuneSkillAdjustEntry>> _allRuneSkillAdjusts;
|
||||||
|
public static HashMap<String, HashMap<ResourceType, Integer>> _effect_costMaps = new HashMap<>();
|
||||||
private static JobScheduler js;
|
private static JobScheduler js;
|
||||||
|
|
||||||
public static void initPowersManager(boolean fullPowersLoad) {
|
public static void initPowersManager(boolean fullPowersLoad) {
|
||||||
|
|||||||
@@ -449,6 +449,9 @@ public class WorldServer {
|
|||||||
Logger.info("Starting Mob Respawn Thread");
|
Logger.info("Starting Mob Respawn Thread");
|
||||||
Respawner.start();
|
Respawner.start();
|
||||||
|
|
||||||
|
Logger.info("Loading effect cost maps");
|
||||||
|
DbManager.EffectsResourceCostsQueries.LOAD_ALL_COSTMAPS();
|
||||||
|
|
||||||
Logger.info("Starting ForgeManager thread");
|
Logger.info("Starting ForgeManager thread");
|
||||||
ForgeManager.start();
|
ForgeManager.start();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user