|
|
@ -14,7 +14,6 @@ import engine.gameManager.DbManager; |
|
|
|
import engine.objects.MobBase; |
|
|
|
import engine.objects.MobBase; |
|
|
|
import engine.objects.MobBaseEffects; |
|
|
|
import engine.objects.MobBaseEffects; |
|
|
|
import engine.objects.MobBaseStats; |
|
|
|
import engine.objects.MobBaseStats; |
|
|
|
import engine.objects.MobLootBase; |
|
|
|
|
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
@ -59,14 +58,28 @@ public class dbMobBaseHandler extends dbHandlerBase { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<MobBase> GET_ALL_MOBBASES() { |
|
|
|
public ArrayList<MobBase> GET_ALL_MOBBASES() { |
|
|
|
prepareCallable("SELECT * FROM `static_npc_mobbase`;"); |
|
|
|
|
|
|
|
return getObjectList(); |
|
|
|
ArrayList<MobBase> mobbaseList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase`;")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
mobbaseList = getObjectsFromRs(rs, 1000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return mobbaseList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void SET_AI_DEFAULTS() { |
|
|
|
public void SET_AI_DEFAULTS() { |
|
|
|
prepareCallable("SELECT * FROM `static_ai_defaults`"); |
|
|
|
|
|
|
|
try { |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_ai_defaults`")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
MBServerStatics.AI_BASE_AGGRO_RANGE = rs.getInt("aggro_range"); |
|
|
|
MBServerStatics.AI_BASE_AGGRO_RANGE = rs.getInt("aggro_range"); |
|
|
|
MBServerStatics.AI_PATROL_DIVISOR = rs.getInt("patrol_chance"); |
|
|
|
MBServerStatics.AI_PATROL_DIVISOR = rs.getInt("patrol_chance"); |
|
|
@ -75,109 +88,101 @@ public class dbMobBaseHandler extends dbHandlerBase { |
|
|
|
MBServerStatics.AI_RECALL_RANGE = rs.getInt("recall_range"); |
|
|
|
MBServerStatics.AI_RECALL_RANGE = rs.getInt("recall_range"); |
|
|
|
MBServerStatics.AI_PET_HEEL_DISTANCE = rs.getInt("pet_heel_distance"); |
|
|
|
MBServerStatics.AI_PET_HEEL_DISTANCE = rs.getInt("pet_heel_distance"); |
|
|
|
} |
|
|
|
} |
|
|
|
rs.close(); |
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.getMessage()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean UPDATE_AI_DEFAULTS() { |
|
|
|
public boolean UPDATE_AI_DEFAULTS() { |
|
|
|
prepareCallable("UPDATE `static_ai_defaults` SET `aggro_range` = ?,`patrol_chance`= ?,`drop_aggro_range`= ?,`cast_chance`= ?,`recall_range`= ? WHERE `ID` = 1"); |
|
|
|
|
|
|
|
setInt(1, MBServerStatics.AI_BASE_AGGRO_RANGE); |
|
|
|
|
|
|
|
setInt(2, MBServerStatics.AI_PATROL_DIVISOR); |
|
|
|
|
|
|
|
setInt(3, MBServerStatics.AI_DROP_AGGRO_RANGE); |
|
|
|
|
|
|
|
setInt(4, MBServerStatics.AI_POWER_DIVISOR); |
|
|
|
|
|
|
|
setInt(5, MBServerStatics.AI_RECALL_RANGE); |
|
|
|
|
|
|
|
return (executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_ai_defaults` SET `aggro_range` = ?,`patrol_chance`= ?,`drop_aggro_range`= ?,`cast_chance`= ?,`recall_range`= ? WHERE `ID` = 1")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, MBServerStatics.AI_BASE_AGGRO_RANGE); |
|
|
|
|
|
|
|
preparedStatement.setInt(2, MBServerStatics.AI_PATROL_DIVISOR); |
|
|
|
|
|
|
|
preparedStatement.setInt(3, MBServerStatics.AI_DROP_AGGRO_RANGE); |
|
|
|
|
|
|
|
preparedStatement.setInt(4, MBServerStatics.AI_POWER_DIVISOR); |
|
|
|
|
|
|
|
preparedStatement.setInt(5, MBServerStatics.AI_RECALL_RANGE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public HashMap<Integer, Integer> LOAD_STATIC_POWERS(int mobBaseUUID) { |
|
|
|
public HashMap<Integer, Integer> LOAD_STATIC_POWERS(int mobBaseUUID) { |
|
|
|
|
|
|
|
|
|
|
|
HashMap<Integer, Integer> powersList = new HashMap<>(); |
|
|
|
HashMap<Integer, Integer> powersList = new HashMap<>(); |
|
|
|
prepareCallable("SELECT * FROM `static_npc_mobbase_powers` WHERE `mobbaseUUID`=?"); |
|
|
|
|
|
|
|
setInt(1, mobBaseUUID); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_powers` WHERE `mobbaseUUID`=?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, mobBaseUUID); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) |
|
|
|
powersList.put(rs.getInt("token"), rs.getInt("rank")); |
|
|
|
powersList.put(rs.getInt("token"), rs.getInt("rank")); |
|
|
|
} |
|
|
|
|
|
|
|
rs.close(); |
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error( e.getMessage()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return powersList; |
|
|
|
return powersList; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<MobBaseEffects> GET_RUNEBASE_EFFECTS(int runeID) { |
|
|
|
public ArrayList<MobBaseEffects> GET_RUNEBASE_EFFECTS(int runeID) { |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<MobBaseEffects> effectsList = new ArrayList<>(); |
|
|
|
ArrayList<MobBaseEffects> effectsList = new ArrayList<>(); |
|
|
|
prepareCallable("SELECT * FROM `static_npc_mobbase_effects` WHERE `mobbaseUUID` = ?"); |
|
|
|
|
|
|
|
setInt(1, runeID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_effects` WHERE `mobbaseUUID` = ?")) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, runeID); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
MobBaseEffects mbs = new MobBaseEffects(rs); |
|
|
|
MobBaseEffects mbs = new MobBaseEffects(rs); |
|
|
|
effectsList.add(mbs); |
|
|
|
effectsList.add(mbs); |
|
|
|
} |
|
|
|
} |
|
|
|
rs.close(); |
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error (e.getMessage()); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return effectsList; |
|
|
|
return effectsList; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public MobBaseStats LOAD_STATS(int mobBaseUUID) { |
|
|
|
public MobBaseStats LOAD_STATS(int mobBaseUUID) { |
|
|
|
MobBaseStats mbs = MobBaseStats.GetGenericStats(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `static_npc_mobbase_stats` WHERE `mobbaseUUID` = ?"); |
|
|
|
MobBaseStats mobBaseStats = MobBaseStats.GetGenericStats(); |
|
|
|
setInt(1, mobBaseUUID); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mbs = new MobBaseStats(rs); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
} |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_stats` WHERE `mobbaseUUID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
preparedStatement.setInt(1, mobBaseUUID); |
|
|
|
Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return mbs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
while (rs.next()) |
|
|
|
|
|
|
|
mobBaseStats = new MobBaseStats(rs); |
|
|
|
|
|
|
|
|
|
|
|
public boolean RENAME_MOBBASE(int ID, String newName) { |
|
|
|
} catch (SQLException e) { |
|
|
|
prepareCallable("UPDATE `static_npc_mobbase` SET `name`=? WHERE `ID`=?;"); |
|
|
|
Logger.error(e); |
|
|
|
setString(1, newName); |
|
|
|
} |
|
|
|
setInt(2, ID); |
|
|
|
return mobBaseStats; |
|
|
|
return (executeUpdate() > 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_ALL_MOBBASE_SPEEDS(MobBase mobBase) { |
|
|
|
public void LOAD_ALL_MOBBASE_SPEEDS(MobBase mobBase) { |
|
|
|
|
|
|
|
|
|
|
|
if (mobBase.getLoadID() == 0) |
|
|
|
if (mobBase.getLoadID() == 0) |
|
|
|
return; |
|
|
|
return; |
|
|
|
ArrayList<MobLootBase> mobLootList = new ArrayList<>(); |
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `static_npc_mobbase_race` WHERE `mobbaseID` = ?"); |
|
|
|
|
|
|
|
setInt(1, mobBase.getLoadID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_mobbase_race` WHERE `mobbaseID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, mobBase.getLoadID()); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
//shrines cached in rs for easy cache on creation.
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
float walk = rs.getFloat("walkStandard"); |
|
|
|
float walk = rs.getFloat("walkStandard"); |
|
|
|
float walkCombat = rs.getFloat("walkCombat"); |
|
|
|
float walkCombat = rs.getFloat("walkCombat"); |
|
|
@ -186,11 +191,8 @@ public class dbMobBaseHandler extends dbHandlerBase { |
|
|
|
mobBase.updateSpeeds(walk, walkCombat, run, runCombat); |
|
|
|
mobBase.updateSpeeds(walk, walkCombat, run, runCombat); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|