StringqueryString="INSERT IGNORE INTO login_cachelist (`UID`) SELECT `UID` from `obj_account` WHERE `discordAccount` = ?";
ConfigManager.MB_DATABASE_PASS.getValue());
PreparedStatementinvalidateAccounts=connection.prepareStatement("INSERT IGNORE INTO login_cachelist (`UID`) SELECT `UID` from `obj_account` WHERE `discordAccount` = ?")){
PreparedStatementstatement=localConnection.prepareStatement(queryString,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);// Make this an updatable result set as we'll reset the dirty flag as we go along
ResultSetrs=statement.executeQuery()){
@ -338,7 +339,7 @@ public class BaneRecord extends DataRecord {
@@ -338,7 +339,7 @@ public class BaneRecord extends DataRecord {
PreparedStatementstatement=localConnection.prepareStatement(queryString,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);// Make this an updatable result set as we'll reset the dirty flag as we go along
ResultSetrs=statement.executeQuery()){
@ -263,7 +264,7 @@ public class CharacterRecord extends DataRecord {
@@ -263,7 +264,7 @@ public class CharacterRecord extends DataRecord {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT b.* FROM `static_rune_baseclass` b, `static_rune_racebaseclass` r WHERE b.`ID` = r.`BaseClassID` && r.`RaceID` = ?")){
preparedStatement.setInt(1,id);
ResultSetrs=preparedStatement.executeQuery();
baseClasses=getObjectsFromRs(rs,20);
}catch(SQLExceptione){
Logger.error(e);
}
returnbaseClasses;
}
publicArrayList<BaseClass>GET_ALL_BASE_CLASSES(){
prepareCallable("SELECT * FROM `static_rune_baseclass`;");
@ -21,16 +27,23 @@ public class dbBuildingLocationHandler extends dbHandlerBase {
@@ -21,16 +27,23 @@ public class dbBuildingLocationHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `accountID`, `characterID`, `machineID` FROM `dyn_session` WHERE `secretKey`=?")){
@ -28,86 +27,143 @@ public class dbCharacterPowerHandler extends dbHandlerBase {
@@ -28,86 +27,143 @@ public class dbCharacterPowerHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_character_power` SET `PowersBaseToken`=?, `CharacterID`=?, `trains`=? WHERE `UID`=?")){
@ -23,41 +25,97 @@ public class dbCharacterRuneHandler extends dbHandlerBase {
@@ -23,41 +25,97 @@ public class dbCharacterRuneHandler extends dbHandlerBase {
@ -29,88 +28,146 @@ public class dbCharacterSkillHandler extends dbHandlerBase {
@@ -29,88 +28,146 @@ public class dbCharacterSkillHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_character_skill` SET `skillsBaseID`=?, `CharacterID`=?, `trains`=? WHERE `UID`=?")){
prepareCallable("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;")){
prepareCallable("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`UID`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`UID`=?;")){
@ -20,11 +26,22 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase {
@@ -20,11 +26,22 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase {
// prepareCallable("SELECT * FROM `obj_character`, `dyn_guild_banishlist` WHERE `obj_character.char_isActive` = 1 AND `dyn_guild_banishlist.CharacterID` = `obj_character.UID` AND `obj_character.GuildID`=?");
//prepareCallable("SELECT * FROM `obj_character` `,` `dyn_guild_banishlist` WHERE obj_character.char_isActive = 1 AND dyn_guild_banishlist.CharacterID = obj_character.UID AND dyn_guild_banishlist.GuildID = ?");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT g.* FROM `obj_guild` g, `dyn_character_guildhistory` l WHERE g.`UID` = l.`GuildID` && l.`CharacterID` = ?")){
// prepareCallable("SELECT * FROM `obj_character`, `dyn_guild_banishlist` WHERE `obj_character.char_isActive` = 1 AND `dyn_guild_banishlist.CharacterID` = `obj_character.UID` AND `obj_character.GuildID`=?");
//prepareCallable("SELECT * FROM `obj_character` `,` `dyn_guild_banishlist` WHERE obj_character.char_isActive = 1 AND dyn_guild_banishlist.CharacterID = obj_character.UID AND dyn_guild_banishlist.GuildID = ?");
prepareCallable("SELECT `obj_guild`.*, `object`.`parent` FROM `obj_guild` INNER JOIN `object` ON `object`.`UID` = `obj_guild`.`UID` WHERE `object`.`UID`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_guild`.*, `object`.`parent` FROM `obj_guild` INNER JOIN `object` ON `object`.`UID` = `obj_guild`.`UID` WHERE `object`.`UID`=?")){
preparedStatement.setLong(1,id);
ResultSetrs=preparedStatement.executeQuery();
guild=(Guild)getObjectFromRs(rs);
}catch(SQLExceptione){
Logger.error(e);
}
returnguild;
}
publicArrayList<Guild>GET_ALL_GUILDS(){
prepareCallable("SELECT `obj_guild`.*, `object`.`parent` FROM `obj_guild` INNER JOIN `object` ON `object`.`UID` = `obj_guild`.`UID`");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `guild_isInnerCouncil`, `guild_isTaxCollector`, `guild_isRecruiter` FROM `obj_character` WHERE `UID`=? && `guildUID`=?")){
preparedStatement.setLong(1,target);
preparedStatement.setLong(2,guildId);
ResultSetrs=preparedStatement.executeQuery();
//If the first query had no results, neither will the second
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")){
prepareCallable("SELECT * FROM `dyn_guild_allianceenemylist` WHERE `GuildID` = ?");
setInt(1,guild.getObjectUUID());
preparedStatement.setLong(1,sourceGuildID);
preparedStatement.setLong(2,targetGuildID);
try{
ResultSetrs=executeQuery();
return(preparedStatement.executeUpdate()>0);
//shrines cached in rs for easy cache on creation.
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `dyn_guild_allianceenemylist` SET `isRecommended` = ?, `isAlliance` = ? WHERE `GuildID`=? AND `OtherGuildID`=?")){
@ -114,10 +104,10 @@ public class dbItemBaseHandler extends dbHandlerBase {
@@ -114,10 +104,10 @@ public class dbItemBaseHandler extends dbHandlerBase {
intruneBaseID;
intrecordsRead=0;
prepareCallable("SELECT * FROM static_npc_runeSet");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT * FROM static_npc_runeSet")){
try{
ResultSetrs=executeQuery();
ResultSetrs=preparedStatement.executeQuery();
while(rs.next()){
@ -130,21 +120,19 @@ public class dbItemBaseHandler extends dbHandlerBase {
@@ -130,21 +120,19 @@ public class dbItemBaseHandler extends dbHandlerBase {
@ -153,13 +141,12 @@ public class dbItemBaseHandler extends dbHandlerBase {
@@ -153,13 +141,12 @@ public class dbItemBaseHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT * FROM static_npc_bootySet")){
try{
ResultSetrs=executeQuery();
ResultSetrs=preparedStatement.executeQuery();
while(rs.next()){
@ -172,21 +159,18 @@ public class dbItemBaseHandler extends dbHandlerBase {
@@ -172,21 +159,18 @@ public class dbItemBaseHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';")){
preparedStatement.setLong(1,targetId);
ResultSetrs=preparedStatement.executeQuery();
itemList=getObjectsFromRs(rs,10);
}catch(SQLExceptione){
Logger.error(e);
returnnull;
}
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`UID`=?;");
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? AND `obj_item`.`item_itembaseID`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`UID`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?");
prepareCallable("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE (`object`.`parent`=? OR `object`.`parent`=?)");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);")){
intnewFromAmt=from.getNumOfItems()-amt;
intnewToAmt=to.getNumOfItems()+amt;
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? THEN ? WHEN `UID`=? THEN ? END WHERE `UID` IN (?, ?);");
prepareCallable("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;")){
prepareCallable("SELECT `obj_item`.*, `object`.`parent` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? AND `obj_item`.`item_container` =?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?")){
//Update an item except ownership
publicbooleanUPDATE_DATABASE(finalItemitem){
prepareCallable("UPDATE `obj_item` SET `item_itembaseID`=?, `item_chargesRemaining`=?, `item_durabilityCurrent`=?, `item_durabilityMax`=?, `item_numberOfItems`=? WHERE `UID`=?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';")){
prepareCallable("UPDATE `obj_item` SET `item_numberOfItems` = CASE WHEN `UID`=? AND `item_numberOfItems`=? THEN ? WHEN `UID`=? AND `item_numberOfItems`=? THEN ? END WHERE `UID` IN (?, ?);");
@ -23,206 +26,190 @@ public class dbLootTableHandler extends dbHandlerBase {
@@ -23,206 +26,190 @@ public class dbLootTableHandler extends dbHandlerBase {
}
publicvoidpopulateLootGroups(){
intrecordsRead=0;
prepareCallable("SELECT `groupID`, `minRoll`, `maxRoll`, `lootTableID`, `pModTableID`, `sModTableID` FROM `static_lootgroups`");
@ -31,125 +33,142 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
@@ -31,125 +33,142 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
prepareCallable("SELECT `obj_character`.*, `object`.`parent` FROM `object` INNER JOIN `obj_character` ON `obj_character`.`UID` = `object`.`UID` WHERE `obj_character`.`char_isActive`='1';");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_character`.*, `object`.`parent` FROM `object` INNER JOIN `obj_character` ON `obj_character`.`UID` = `object`.`UID` WHERE `obj_character`.`char_isActive`='1';")){
@ -157,245 +176,395 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
@@ -157,245 +176,395 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `char_firstname` FROM `obj_character` WHERE `char_isActive`=1 && `char_firstname`=?")){
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_character` SET `char_firstname`=?, `char_lastname`=? WHERE `char_firstname`=? AND `char_isActive`='1'")){
preparedStatement.setString(1,newFirstName);
preparedStatement.setString(2,newLastName);
preparedStatement.setString(3,oldFirstName);
return(preparedStatement.executeUpdate()>0);
}catch(SQLExceptione){
Logger.error(e);
}
returnfalse;
}
publicbooleanSET_DELETED(finalPlayerCharacterpc){
prepareCallable("UPDATE `obj_character` SET `char_isActive`=? WHERE `UID` = ?");
PreparedStatementpreparedStatement=connection.prepareStatement("UPDATE `obj_character` SET `char_strMod`=?, `char_dexMod`=?, `char_conMod`=?, `char_intMod`=?, `char_spiMod`=? WHERE `UID`=?")){
@ -24,31 +27,59 @@ public class dbPromotionClassHandler extends dbHandlerBase {
@@ -24,31 +27,59 @@ public class dbPromotionClassHandler extends dbHandlerBase {
@ -20,15 +26,21 @@ public class dbRuneBaseAttributeHandler extends dbHandlerBase {
@@ -20,15 +26,21 @@ public class dbRuneBaseAttributeHandler extends dbHandlerBase {
@ -25,34 +30,48 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase {
@@ -25,34 +30,48 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase {
@ -60,8 +79,7 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase {
@@ -60,8 +79,7 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase {
@ -123,10 +147,10 @@ public class dbRuneBaseHandler extends dbHandlerBase {
@@ -123,10 +147,10 @@ public class dbRuneBaseHandler extends dbHandlerBase {
runeSets=newHashMap<>();
intrecordsRead=0;
prepareCallable("SELECT * FROM static_rune_racerune");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT * FROM static_rune_racerune")){
try{
ResultSetrs=executeQuery();
ResultSetrs=preparedStatement.executeQuery();
while(rs.next()){
@ -139,35 +163,17 @@ public class dbRuneBaseHandler extends dbHandlerBase {
@@ -139,35 +163,17 @@ public class dbRuneBaseHandler extends dbHandlerBase {
prepareCallable("SELECT `obj_shrine`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_shrine` ON `object`.`UID` = `obj_shrine`.`UID` WHERE `object`.`type` = 'shrine';");
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_shrine`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_shrine` ON `object`.`UID` = `obj_shrine`.`UID` WHERE `object`.`type` = 'shrine';")){
try{
ResultSetrs=executeQuery();
ResultSetrs=preparedStatement.executeQuery();
//shrines cached in rs for easy cache on creation.
@ -98,25 +119,19 @@ public class dbSkillBaseHandler extends dbHandlerBase {
@@ -98,25 +119,19 @@ public class dbSkillBaseHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT * FROM `static_skill_skillsgranted`")){
try{
ResultSetrs=executeQuery();
ResultSetrs=preparedStatement.executeQuery();
//shrines cached in rs for easy cache on creation.
while(rs.next()){
intruneID=rs.getInt("runeID");
@ -129,15 +144,9 @@ public class dbSkillBaseHandler extends dbHandlerBase {
@@ -129,15 +144,9 @@ public class dbSkillBaseHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT IDString, type FROM static_power_failcondition where powerOrEffect = 'Power'")){
@ -21,11 +27,24 @@ public class dbVendorDialogHandler extends dbHandlerBase {
@@ -21,11 +27,24 @@ public class dbVendorDialogHandler extends dbHandlerBase {
@ -54,396 +57,500 @@ public class dbWarehouseHandler extends dbHandlerBase {
@@ -54,396 +57,500 @@ public class dbWarehouseHandler extends dbHandlerBase {
PreparedStatementpreparedStatement=connection.prepareStatement("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';")){
prepareCallable("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';");
@ -156,8 +154,16 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
@@ -156,8 +154,16 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
@ -289,6 +295,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
@@ -289,6 +295,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
Logger.warn("Warning! WorldServerMap with ID "+zone.getObjectUUID()+" has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
Logger.warn("Warning! WorldServerMap with ID "+zone.getObjectUUID()+" has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
@ -449,9 +449,9 @@ public class LoginServerMsgHandler implements NetMsgHandler {
@@ -449,9 +449,9 @@ public class LoginServerMsgHandler implements NetMsgHandler {
PreparedStatementstatement=connection.prepareStatement("SELECT * from `object` where `type` = 'item' AND `parent` IS NULL",ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);