forked from MagicBane/Server
Refactored out duplicate db interface.
This commit is contained in:
@@ -13,10 +13,11 @@ import engine.Enum;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import engine.powers.EffectsBase;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -28,16 +29,17 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
}
|
||||
|
||||
public static void addAllSourceTypes() {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_sourcetype");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_sourcetype")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
String IDString, source;
|
||||
|
||||
while (rs.next()) {
|
||||
IDString = rs.getString("IDString");
|
||||
int token = DbManager.hasher.SBStringHash(IDString);
|
||||
|
||||
|
||||
source = rs.getString("source").replace("-", "").trim();
|
||||
Enum.EffectSourceType effectSourceType = Enum.EffectSourceType.GetEffectSourceType(source);
|
||||
|
||||
@@ -46,19 +48,18 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
|
||||
EffectsBase.effectSourceTypeMap.get(token).add(effectSourceType);
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addAllAnimationOverrides() {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_animation_override");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_animation_override")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
String IDString;
|
||||
int animation;
|
||||
while (rs.next()) {
|
||||
@@ -72,12 +73,10 @@ public class dbPowerHandler extends dbHandlerBase {
|
||||
PowersManager.AnimationOverrides.put(IDString, animation);
|
||||
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,22 +84,6 @@ public abstract class AbstractGameObject {
|
||||
return GameObjectType.values()[ordinal];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a {@link PreparedStatementShared} based on the specified query.
|
||||
* <p>
|
||||
* If {@link AbstractGameObject} Database functions will properly release
|
||||
* the PreparedStatementShared upon completion. If these functions are not
|
||||
* used, then {@link PreparedStatementShared#release release()} must be
|
||||
* called when finished with this object.
|
||||
*
|
||||
* @param sql The SQL string used to generate the PreparedStatementShared
|
||||
* @return {@link PreparedStatementShared}
|
||||
* @throws {@link SQLException}
|
||||
**/
|
||||
protected static PreparedStatementShared prepareStatement(String sql) throws SQLException {
|
||||
return new PreparedStatementShared(sql);
|
||||
}
|
||||
|
||||
public static AbstractGameObject getFromTypeAndID(long compositeID) {
|
||||
int objectTypeID = extractTypeOrdinal(compositeID);
|
||||
int tableID = extractTableID(objectTypeID, compositeID);
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class LevelDefault {
|
||||
|
||||
public static ConcurrentHashMap<Byte, LevelDefault> defaults = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
public final int level;
|
||||
public final float health;
|
||||
public final float mana;
|
||||
public final float stamina;
|
||||
public final float atr;
|
||||
public final float def;
|
||||
public final float minDamage;
|
||||
public final float maxDamage;
|
||||
public final int goldMin;
|
||||
public final int goldMax;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
public LevelDefault(ResultSet rs) throws SQLException {
|
||||
super();
|
||||
this.level = rs.getInt("level");
|
||||
this.health = rs.getFloat("health");
|
||||
this.mana = (float) rs.getInt("mana");
|
||||
this.stamina = (float) rs.getInt("stamina");
|
||||
this.atr = (float) rs.getInt("atr");
|
||||
this.def = (float) rs.getInt("def");
|
||||
this.minDamage = (float) rs.getInt("minDamage");
|
||||
this.maxDamage = (float) rs.getInt("maxDamage");
|
||||
this.goldMin = rs.getInt("goldMin");
|
||||
this.goldMax = rs.getInt("goldMax");
|
||||
}
|
||||
|
||||
public static LevelDefault getLevelDefault(byte level) {
|
||||
LevelDefault ret = null;
|
||||
if (LevelDefault.defaults.containsKey(level))
|
||||
return LevelDefault.defaults.get(level);
|
||||
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM `static_npc_level_defaults` WHERE level = ?;");
|
||||
ps.setInt(1, (int) level);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
ret = new LevelDefault(rs);
|
||||
LevelDefault.defaults.put(level, ret);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error("SQL Error number: " + e.getErrorCode() + ' ' + e.getMessage());
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,12 @@
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.server.MBServerStatics;
|
||||
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;
|
||||
@@ -86,18 +89,26 @@ public class PowerGrant extends AbstractGameObject {
|
||||
}
|
||||
|
||||
public static void fillGrantedPowers() {
|
||||
|
||||
PowerGrant.grantedPowers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = prepareStatement("SELECT * FROM static_power_powergrant");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_powergrant")) {
|
||||
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
if (PowerGrant.grantedPowers.size() > 0) {
|
||||
rs.close();
|
||||
return;
|
||||
}
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
int token = rs.getInt("powerToken");
|
||||
PowerGrant pg = null;
|
||||
|
||||
PowerGrant pg;
|
||||
|
||||
if (PowerGrant.grantedPowers.containsKey(token)) {
|
||||
pg = PowerGrant.grantedPowers.get(token);
|
||||
pg.addRuneGrant(rs.getInt("runeID"), rs.getShort("grantAmount"));
|
||||
@@ -109,16 +120,9 @@ public class PowerGrant extends AbstractGameObject {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
Logger.error("SQL Error number: " + e.getErrorCode(), e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, Short> getRuneGrants() {
|
||||
return this.runeGrants;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Database
|
||||
*/
|
||||
|
||||
@@ -9,11 +9,14 @@
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.powers.PowersBase;
|
||||
import engine.server.MBServerStatics;
|
||||
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;
|
||||
@@ -87,15 +90,18 @@ public class PowerReq extends AbstractGameObject implements Comparable<PowerReq>
|
||||
}
|
||||
|
||||
public static ConcurrentHashMap<Integer, ArrayList<PowerReq>> fillRunePowers() {
|
||||
|
||||
PowerReq.runePowers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = prepareStatement("SELECT * FROM static_power_powerrequirement");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_powerrequirement")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
if (PowerReq.runePowers.size() > 0) {
|
||||
rs.close();
|
||||
return PowerReq.runePowers;
|
||||
}
|
||||
|
||||
while (rs.next()) {
|
||||
ArrayList<PowerReq> runePR = null;
|
||||
int runeID = rs.getInt("runeID");
|
||||
@@ -130,9 +136,8 @@ public class PowerReq extends AbstractGameObject implements Comparable<PowerReq>
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error("SQL Error number: " + e.getErrorCode(), e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
return PowerReq.runePowers;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,11 +12,17 @@ package engine.powers;
|
||||
import engine.Enum.ModType;
|
||||
import engine.Enum.SourceType;
|
||||
import engine.Enum.StackType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.objects.*;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.PlayerBonuses;
|
||||
import engine.objects.Runegate;
|
||||
import engine.powers.poweractions.AbstractPowerAction;
|
||||
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;
|
||||
@@ -133,13 +139,15 @@ public class ActionsBase {
|
||||
// }
|
||||
|
||||
public static void getActionsBase(HashMap<String, PowersBase> powers, HashMap<String, AbstractPowerAction> apa) {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_action");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_action")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
String IDString;
|
||||
ActionsBase toAdd;
|
||||
PowersBase pb;
|
||||
|
||||
while (rs.next()) {
|
||||
IDString = rs.getString("powerID");
|
||||
pb = powers.get(IDString);
|
||||
@@ -151,11 +159,10 @@ public class ActionsBase {
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
int gateID = 5000;
|
||||
|
||||
for (String IDString : Runegate.GetAllOpenGateIDStrings()) {
|
||||
gateID++;
|
||||
ActionsBase openGateActionBase = new ActionsBase(gateID, "OPENGATE", 5, 9999, 0, 0, true, "IgnoreStack", 0, true, false, false, PowersManager.getPowerActionByIDString("OPENGATE"));
|
||||
|
||||
@@ -29,6 +29,8 @@ import engine.powers.effectmodifiers.AbstractEffectModifier;
|
||||
import engine.server.MBServerStatics;
|
||||
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;
|
||||
@@ -169,21 +171,21 @@ public class EffectsBase {
|
||||
}
|
||||
|
||||
public static void getFailConditions(HashMap<String, EffectsBase> effects) {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_failcondition WHERE powerOrEffect = 'Effect';");
|
||||
|
||||
ResultSet rs = ps.executeQuery();
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_failcondition WHERE powerOrEffect = 'Effect';")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
PowerFailCondition failCondition = null;
|
||||
|
||||
Object value;
|
||||
while (rs.next()) {
|
||||
String fail = rs.getString("type");
|
||||
|
||||
|
||||
String IDString = rs.getString("IDString");
|
||||
int token = DbManager.hasher.SBStringHash(IDString);
|
||||
failCondition = PowerFailCondition.valueOf(fail);
|
||||
|
||||
if (failCondition == null) {
|
||||
Logger.error("Couldn't Find FailCondition " + fail + " for " + IDString);
|
||||
continue;
|
||||
@@ -200,11 +202,10 @@ public class EffectsBase {
|
||||
|
||||
case TakeDamage:
|
||||
|
||||
|
||||
// dont go any further.
|
||||
if (eb == null) {
|
||||
|
||||
if (eb == null)
|
||||
break;
|
||||
}
|
||||
|
||||
eb.cancelOnTakeDamage = true;
|
||||
|
||||
@@ -217,7 +218,6 @@ public class EffectsBase {
|
||||
String damageType2 = rs.getString("damageType2");
|
||||
String damageType3 = rs.getString("damageType3");
|
||||
|
||||
|
||||
if (damageType1.isEmpty() && damageType2.isEmpty() && damageType3.isEmpty())
|
||||
break;
|
||||
|
||||
@@ -274,10 +274,7 @@ public class EffectsBase {
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Enum.SourceType getDamageType(String name) {
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.powers;
|
||||
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class FailCondition {
|
||||
|
||||
private String IDString;
|
||||
private Boolean forPower;
|
||||
private String type;
|
||||
private float amount;
|
||||
private float ramp;
|
||||
private boolean rampAdd;
|
||||
|
||||
// private String damageType1;
|
||||
// private String damageType2;
|
||||
// private String damageType3;
|
||||
|
||||
/**
|
||||
* No Table ID Constructor
|
||||
*/
|
||||
public FailCondition() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
public FailCondition(ResultSet rs) throws SQLException {
|
||||
|
||||
this.IDString = rs.getString("IDString");
|
||||
this.forPower = (rs.getString("powerOrEffect").equals("Power")) ? true : false;
|
||||
this.type = rs.getString("type");
|
||||
this.amount = rs.getFloat("amount");
|
||||
this.ramp = rs.getFloat("ramp");
|
||||
this.rampAdd = (rs.getInt("useAddFormula") == 1) ? true : false;
|
||||
// this.damageType1 = rs.getString("damageType1");
|
||||
// this.damageType2 = rs.getString("damageType2");
|
||||
// this.damageType3 = rs.getString("damageType3");
|
||||
}
|
||||
|
||||
public static ArrayList<FailCondition> getAllFailConditions() {
|
||||
PreparedStatementShared ps = null;
|
||||
ArrayList<FailCondition> out = new ArrayList<>();
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM failconditions");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
FailCondition toAdd = new FailCondition(rs);
|
||||
out.add(toAdd);
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public String getIDString() {
|
||||
return this.IDString;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean forPower() {
|
||||
return this.forPower;
|
||||
}
|
||||
|
||||
public float getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public float getRamp() {
|
||||
return this.ramp;
|
||||
}
|
||||
|
||||
public float getAmountForTrains(float trains) {
|
||||
if (this.rampAdd)
|
||||
return this.amount + (this.ramp * trains);
|
||||
else
|
||||
return this.amount * (1 + (this.ramp * trains));
|
||||
}
|
||||
|
||||
public boolean useRampAdd() {
|
||||
return this.rampAdd;
|
||||
}
|
||||
|
||||
// public String getDamageType1() {
|
||||
// return this.damageType1;
|
||||
// }
|
||||
|
||||
// public String getDamageType2() {
|
||||
// return this.damageType2;
|
||||
// }
|
||||
|
||||
// public String getDamageType3() {
|
||||
// return this.damageType3;
|
||||
// }
|
||||
}
|
||||
@@ -9,9 +9,11 @@
|
||||
|
||||
package engine.powers;
|
||||
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import engine.gameManager.DbManager;
|
||||
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;
|
||||
@@ -60,14 +62,17 @@ public class PowerPrereq {
|
||||
}
|
||||
|
||||
public static void getAllPowerPrereqs(HashMap<String, PowersBase> powers) {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_powercastprereq");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
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);
|
||||
@@ -85,8 +90,6 @@ public class PowerPrereq {
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,13 @@ import engine.math.Vector3fImmutable;
|
||||
import engine.objects.AbstractCharacter;
|
||||
import engine.objects.AbstractWorldObject;
|
||||
import engine.objects.Item;
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import engine.powers.ActionsBase;
|
||||
import engine.powers.EffectsBase;
|
||||
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.HashMap;
|
||||
@@ -64,11 +65,14 @@ public abstract class AbstractPowerAction {
|
||||
}
|
||||
|
||||
public static void getAllPowerActions(HashMap<String, AbstractPowerAction> powerActions, HashMap<Integer, AbstractPowerAction> powerActionsByID, HashMap<String, EffectsBase> effects) {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_poweraction");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_poweraction")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
String IDString, type;
|
||||
|
||||
while (rs.next()) {
|
||||
AbstractPowerAction apa;
|
||||
type = rs.getString("type");
|
||||
@@ -185,45 +189,14 @@ public abstract class AbstractPowerAction {
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
|
||||
//Add OpenGatePowerAction
|
||||
AbstractPowerAction openGateAction = new OpenGatePowerAction(5000, "OPENGATE", "OpenGate", false, 0);
|
||||
powerActions.put("OPENGATE", openGateAction);
|
||||
powerActionsByID.put(openGateAction.UUID, openGateAction);
|
||||
}
|
||||
|
||||
public static void loadValidItemFlags(HashMap<String, AbstractPowerAction> powerActions) {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM `static_power_effect_allowed_item`");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
String IDS;
|
||||
long flags;
|
||||
while (rs.next()) {
|
||||
AbstractPowerAction apa;
|
||||
flags = rs.getLong("flags");
|
||||
IDS = rs.getString("IDString");
|
||||
if (powerActions.containsKey(IDS)) {
|
||||
apa = powerActions.get(IDS);
|
||||
apa.validItemFlags = flags;
|
||||
} else {
|
||||
Logger.error("Unable to find PowerAction " + IDS);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int numTrains, ActionsBase ab, PowersBase pb) {
|
||||
this._startAction(source, awo, targetLoc, numTrains, ab, pb);
|
||||
}
|
||||
|
||||
@@ -311,12 +311,6 @@ public class LoginServer {
|
||||
return false;
|
||||
}
|
||||
|
||||
PreparedStatementShared.submitPreparedStatementsCleaningJob();
|
||||
|
||||
if (MBServerStatics.DB_DEBUGGING_ON_BY_DEFAULT) {
|
||||
PreparedStatementShared.enableDebugging();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -534,12 +534,6 @@ public class WorldServer {
|
||||
return false;
|
||||
}
|
||||
|
||||
PreparedStatementShared.submitPreparedStatementsCleaningJob();
|
||||
|
||||
if (MBServerStatics.DB_DEBUGGING_ON_BY_DEFAULT) {
|
||||
PreparedStatementShared.enableDebugging();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user