Remove the DB power, cast prereq and power fail condition loaders

getAllPowersBase, getFailConditions, PowerPrereq.getAllPowerPrereqs and
the PowersBase/PowerPrereq ResultSet constructors. Powers come from
Powers.cfg since ac72d2c8 (tested).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-26 10:09:31 -04:00
1 parent ac72d2c8d2
commit f44f1ca138
3 files changed
-296

No files matched your search

@@ -9,18 +9,8 @@
package engine.db.handlers;
import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.objects.SkillReq;
import engine.powers.PowersBase;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
public class dbSkillReqHandler extends dbHandlerBase {
@@ -28,52 +18,4 @@ public class dbSkillReqHandler extends dbHandlerBase {
this.localClass = SkillReq.class;
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public static ArrayList<PowersBase> getAllPowersBase() {
ArrayList<PowersBase> powerBaseList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_powerbase")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
PowersBase toAdd = new PowersBase(rs);
powerBaseList.add(toAdd);
}
} catch (SQLException e) {
Logger.error(e);
}
return powerBaseList;
}
public static void getFailConditions(HashMap<String, PowersBase> powers) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT IDString, type FROM static_power_failcondition where powerOrEffect = 'Power'")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
String type = rs.getString("type");
String IDString = rs.getString("IDString");
PowersBase pb = powers.get(IDString);
if (pb != null)
switch (type) {
case "CastSpell":
pb.cancelOnCastSpell = true;
break;
case "TakeDamage":
pb.cancelOnTakeDamage = true;
break;
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
}
-68
View File
@@ -9,16 +9,8 @@
package engine.powers;
import engine.gameManager.DbManager;
import engine.mbEnums.EquipSlotType;
import engine.parsers.objects.wpak.PowerTemplate;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
public class PowerPrereq {
@@ -35,34 +27,6 @@ public class PowerPrereq {
}
/**
* ResultSet Constructor
*/
public PowerPrereq(ResultSet rs, int type) throws SQLException {
// this.IDString = rs.getString("IDString");
if (type == 1) {
this.effect = rs.getString("messageone");
this.message = rs.getString("messagetwo");
this.mainHand = false;
this.required = false;
} else if (type == 2) {
String sl = rs.getString("messageone");
if (sl.equals("RHELD"))
this.mainHand = true;
else if (sl.equals("LHELD"))
this.mainHand = false;
this.effect = "";
this.message = rs.getString("messagetwo");
this.required = (rs.getInt("required") == 1) ? true : false;
} else { //targetEffectPrereq
this.effect = rs.getString("messageone");
this.message = "";
this.mainHand = false;
this.required = (rs.getInt("required") == 1) ? true : false;
}
}
// EFFECTPREREQ= on the caster
public PowerPrereq(PowerTemplate.EffectPrereq effectPrereq) {
@@ -90,38 +54,6 @@ public class PowerPrereq {
this.required = equipPrereq.required;
}
public static void getAllPowerPrereqs(HashMap<String, PowersBase> powers) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_powercastprereq;")) {
ResultSet rs = preparedStatement.executeQuery();
int type;
String IDString;
PowerPrereq toAdd;
PowersBase pb;
while (rs.next()) {
IDString = rs.getString("IDString");
pb = powers.get(IDString);
if (pb != null) {
type = rs.getInt("Type");
toAdd = new PowerPrereq(rs, type);
if (type == 1)
pb.getEffectPrereqs().add(toAdd);
else if (type == 2)
pb.getEquipPrereqs().add(toAdd);
else
pb.getTargetEffectPrereqs().add(toAdd);
}
}
rs.close();
} catch (Exception e) {
Logger.error(e.toString());
}
}
public String getEffect() {
return this.effect;
}
-170
View File
@@ -18,15 +18,12 @@ import engine.mbEnums.PowerCategoryType;
import engine.mbEnums.PowerTargetType;
import engine.mbEnums.PowerType;
import engine.mbEnums.TargetSelectType;
import engine.parsers.cache.CacheParserUtil;
import engine.parsers.objects.wpak.CurveRamp;
import engine.parsers.objects.wpak.EffectTemplate;
import engine.parsers.objects.wpak.PowerTemplate;
import engine.util.Hasher;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.EnumSet;
@@ -131,173 +128,6 @@ public class PowersBase {
}
/**
* ResultSet Constructor
*/
public PowersBase(ResultSet rs) throws SQLException {
this.UUID = rs.getInt("ID");
this.name = rs.getString("name").trim();
this.token = rs.getInt("token");
this.skillName = rs.getString("skillName").trim();
this.IDString = rs.getString("IDString").trim();
this.isSpell = (rs.getString("skillOrSpell").equals("SPELL")) ? true : false;
this.skillID = rs.getInt("skillID");
this.range = rs.getFloat("range");
this.description = (rs.getString("description")).trim().replace("\r\n ", "");
String ct = rs.getString("costType").trim();
if (ct.equals("HEALTH"))
this.useHealth = true;
else if (ct.equals("MANA"))
this.useMana = true;
else if (ct.equals("STAMINA"))
this.useStamina = true;
this.setTargetType(rs.getString("targetType").trim());
String cat = rs.getString("category").trim();
this.category = cat;
if (cat.isEmpty())
this.powerCategory = PowerCategoryType.NONE;
else
this.powerCategory = PowerCategoryType.valueOf(cat.replace("-", ""));
if (cat.equals("WEAPON")) {
this.isWeaponPower = true;
this.isHarmful = false;
if (this.skillName.equals("Bow") || this.skillName.equals("Crossbow") || this.skillName.equals("Archery"))
this.weaponRange = 1000f;
else if (this.skillName.equals("Throwing"))
this.weaponRange = 60f;
else
this.weaponRange = 15f;
} else if (cat.equals("HEAL") || cat.equals("GROUPHEAL")) {
this.isHeal = true;
this.isHarmful = false;
} else if (cat.equals("TRACK")) {
this.isTrack = true;
this.isHarmful = false;
} else if (cat.equals("AE") || cat.equals("AEDAMAGE") ||
cat.equals("BREAKFLY") ||
cat.equals("DAMAGE") || cat.equals("DEBUFF") ||
cat.equals("MOVE") || cat.equals("SPECIAL") ||
cat.equals("SPIREDISABLE"))
this.isHarmful = true;
else if (cat.equals("CHANT")) {
this.isHarmful = ct.equals("MOBILE") || ct.equals("PC") || ct.equals("PCMOBILE");
} else if (cat.equals("DISPEL")) {
//TODO this needs broken down better later
this.isHarmful = false;
} else if (cat.isEmpty()) {
if (ct.equals("MOBILE") || ct.equals("PCMOBILE"))
this.isHarmful = true;
else if (ct.equals("PC")) {
this.isHarmful = this.token != 429607195 && this.token != 429425915;
} else
this.isHarmful = false;
} else
this.isHarmful = false;
if (cat.equals("VAMPDRAIN")) {
this.vampDrain = true;
this.isHarmful = true;
}
this.cost = rs.getFloat("cost");
this.costRamp = rs.getFloat("costRamp");
this.castTime = rs.getFloat("castTime");
this.castTimeRamp = rs.getFloat("initRamp");
this.cooldown = rs.getFloat("cooldown");
this.recycleTime = rs.getFloat("recycleTime");
this.recycleRamp = rs.getFloat("recycleRamp");
this.maxTrains = rs.getInt("maxTrains");
this.hateValue = rs.getFloat("hateValue");
this.hateRamp = rs.getFloat("hateRamp");
ct = rs.getString("unknown06").trim();
if (this.targetSelf) {
} else if (ct.equals("CLICK"))
if (!this.targetGroup)
this.targetFromLastTarget = true;
else if (ct.equals("NAME"))
this.targetFromName = true;
else if (ct.equals("NEARBYMOBS"))
this.targetFromNearbyMobs = true;
this.monsterTypePrereq = rs.getString("monsterTypePrereqs").trim();
ct = rs.getString("radiusType").trim();
if (ct.equals("CONE"))
this.useCone = true;
else if (ct.equals("POINTBLANK"))
this.usePointBlank = true;
else if (ct.equals("SPHERE"))
this.useSphere = true;
else
this.isAOE = false;
this.radius = rs.getFloat("radius");
ct = rs.getString("groupReq").trim();
if (ct.equals("CASTER"))
this.isCasterFriendly = true;
else if (ct.equals("GROUP")) {
this.isGroupFriendly = true;
this.isCasterFriendly = true;
} else if (ct.equals("ALLBUTGROUP"))
this.isGroupOnly = true;
else if (ct.equals("ALLBUTPETS"))
this.mustHitPets = true;
else if (ct.equals("NATION")) {
this.isNationFriendly = true;
this.isCasterFriendly = true;
}
this.maxNumMobTargets = rs.getInt("maxNumMobTargets");
this.maxNumPlayerTargets = rs.getInt("maxNumPlayerTargets");
this.chantDuration = rs.getFloat("chantDuration");
this.chantIterations = rs.getInt("chantIterations");
ct = rs.getString("combat").trim();
if (ct.equals("COMBAT"))
this.allowedInCombat = true;
else if (ct.equals("NONCOMBAT"))
this.allowedOutOfCombat = true;
else if (ct.equals("BOTH")) {
this.allowedInCombat = true;
this.allowedOutOfCombat = true;
}
ct = rs.getString("grantOverideVar").trim();
if (ct.equals("PGOV_PLAYER"))
this.regularPlayerCanCast = true;
int flags = rs.getInt("flags");
if ((flags & 1) == 0)
this.hateRampAdd = false;
if ((flags & 2) == 0)
this.costRampAdd = false;
if ((flags & 4) == 0)
this.recycleRampAdd = false;
if ((flags & 8) == 0)
this.initRampAdd = false;
if ((flags & 16) != 0)
this.canCastWhileMoving = true;
if ((flags & 32) != 0)
this.canCastWhileFlying = true;
if ((flags & 64) != 0)
this.isChant = true;
if ((flags & 128) != 0)
this.losCheck = true;
if ((flags & 256) != 0)
this.sticky = true;
if ((flags & 512) != 0)
this.isAdminPower = true;
if ((flags & 1024) != 0)
this.requiresHitRoll = true;
ct = rs.getString("monsterTypeRestrict1").trim();
if (!ct.isEmpty())
this.monsterTypeRestrictions.add(CacheParserUtil.readEnum(MonsterType.class, ct, this.UUID, "monsterTypeRestrict1"));
ct = rs.getString("monsterTypeRestrict2").trim();
if (!ct.isEmpty())
this.monsterTypeRestrictions.add(CacheParserUtil.readEnum(MonsterType.class, ct, this.UUID, "monsterTypeRestrict2"));
ct = rs.getString("monsterTypeRestrict3").trim();
if (!ct.isEmpty())
this.monsterTypeRestrictions.add(CacheParserUtil.readEnum(MonsterType.class, ct, this.UUID, "monsterTypeRestrict3"));
}
public PowersBase(PowerTemplate powerTemplate, int id) {
CurveRamp hateRamp;