Sync with L2jServer HighFive Jul 25th 2015.

This commit is contained in:
MobiusDev
2015-07-26 10:59:25 +00:00
parent 83854bc5e5
commit 1fc14085f5
161 changed files with 2288 additions and 2181 deletions

View File

@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.SpawnTable;
import com.l2jserver.gameserver.idfactory.IdFactory;
@@ -118,7 +118,7 @@ public class AutoSpawnHandler
private void restoreSpawnData()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM random_spawn ORDER BY groupId ASC");
PreparedStatement ps = con.prepareStatement("SELECT * FROM random_spawn_loc WHERE groupId=?"))

View File

@@ -28,7 +28,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
@@ -57,7 +57,7 @@ public class BlockList
private void addToBlockList(int target)
{
_blockList.put(target, "");
updateInDB(target, true);
persistInDB(target);
}
private void removeFromBlockList(int target)
@@ -67,7 +67,7 @@ public class BlockList
{
_updateMemos.remove(Integer.valueOf(target));
}
updateInDB(target, false);
removeFromDB(target);
}
public void setBlockMemo(int target, String memo)
@@ -81,16 +81,16 @@ public class BlockList
public void updateBlockMemos()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
for (int target : _updateMemos)
{
try (PreparedStatement statement = con.prepareStatement("UPDATE character_friends SET memo=? WHERE charId=? AND friendId=? AND relation=1"))
try (PreparedStatement ps = con.prepareStatement("UPDATE character_friends SET memo=? WHERE charId=? AND friendId=? AND relation=1"))
{
statement.setString(1, _blockList.get(target));
statement.setInt(2, _owner.getObjectId());
statement.setInt(3, target);
statement.execute();
ps.setString(1, _blockList.get(target));
ps.setInt(2, _owner.getObjectId());
ps.setInt(3, target);
ps.execute();
}
}
}
@@ -110,21 +110,21 @@ public class BlockList
private static HashMap<Integer, String> loadList(int ObjId)
{
HashMap<Integer, String> list = new HashMap<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=1"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT friendId, memo FROM character_friends WHERE charId=? AND relation=1"))
{
statement.setInt(1, ObjId);
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, ObjId);
try (ResultSet rs = ps.executeQuery())
{
int friendId;
while (rset.next())
while (rs.next())
{
friendId = rset.getInt("friendId");
friendId = rs.getInt("friendId");
if (friendId == ObjId)
{
continue;
}
String memo = rset.getString("memo");
String memo = rs.getString("memo");
list.put(friendId, memo);
}
}
@@ -136,33 +136,33 @@ public class BlockList
return list;
}
private void updateInDB(int targetId, boolean state)
private void removeFromDB(int targetId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
{
if (state) // add
{
try (PreparedStatement statement = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
{
statement.setInt(1, _owner.getObjectId());
statement.setInt(2, targetId);
statement.execute();
}
}
else
// remove
{
try (PreparedStatement statement = con.prepareStatement("DELETE FROM character_friends WHERE charId=? AND friendId=? AND relation=1"))
{
statement.setInt(1, _owner.getObjectId());
statement.setInt(2, targetId);
statement.execute();
}
}
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, targetId);
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not add block player: " + e.getMessage(), e);
_log.log(Level.WARNING, "Could not remove blocked player: " + e.getMessage(), e);
}
}
private void persistInDB(int targetId)
{
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_friends (charId, friendId, relation) VALUES (?, ?, 1)"))
{
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, targetId);
ps.execute();
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not add blocked player: " + e.getMessage(), e);
}
}

View File

@@ -26,7 +26,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.xml.impl.TransformData;
import com.l2jserver.gameserver.datatables.SkillData;
@@ -140,7 +140,7 @@ public class CursedWeapon implements INamable
// Remove from Db
_log.info(_name + " being removed offline.");
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement del = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
PreparedStatement ps = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE charId=?"))
{
@@ -486,7 +486,7 @@ public class CursedWeapon implements INamable
_log.info("CursedWeapon: Saving data to disk.");
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement del = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
PreparedStatement ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerKarma, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
{

View File

@@ -36,7 +36,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.communitybbs.BB.Forum;
import com.l2jserver.gameserver.communitybbs.Manager.ForumsBBSManager;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
@@ -248,7 +248,7 @@ public class L2Clan implements IIdentifiable, INamable
}
else
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
{
ps.setInt(1, 0);
@@ -288,7 +288,7 @@ public class L2Clan implements IIdentifiable, INamable
}
else
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
{
ps.setInt(1, EnumIntBitmask.getAllBitmask(ClanPrivilege.class));
@@ -842,7 +842,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void updateBloodAllianceCountInDB()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_alliance_count=? WHERE clan_id=?"))
{
ps.setInt(1, getBloodAllianceCount());
@@ -886,7 +886,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void updateBloodOathCountInDB()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_oath_count=? WHERE clan_id=?"))
{
ps.setInt(1, getBloodOathCount());
@@ -904,7 +904,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void updateClanScoreInDB()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET reputation_score=? WHERE clan_id=?"))
{
ps.setInt(1, getReputationScore());
@@ -933,7 +933,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void updateClanInDB()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET leader_id=?,ally_id=?,ally_name=?,reputation_score=?,ally_penalty_expiry_time=?,ally_penalty_type=?,char_penalty_expiry_time=?,dissolving_expiry_time=?,new_leader_id=? WHERE clan_id=?"))
{
ps.setInt(1, getLeaderId());
@@ -975,7 +975,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
public void store()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
{
ps.setInt(1, getId());
@@ -1011,7 +1011,7 @@ public class L2Clan implements IIdentifiable, INamable
*/
private void removeMemberInDatabase(int playerId, long clanJoinExpiryTime, long clanCreateExpiryTime)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
@@ -1037,7 +1037,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restore()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
{
ps.setInt(1, getId());
@@ -1117,7 +1117,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreNotice()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT enabled,notice FROM clan_notices WHERE clan_id=?"))
{
ps.setInt(1, getId());
@@ -1148,7 +1148,7 @@ public class L2Clan implements IIdentifiable, INamable
notice = notice.substring(0, MAX_NOTICE_LENGTH - 1);
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_notices (clan_id,notice,enabled) values (?,?,?) ON DUPLICATE KEY UPDATE notice=?,enabled=?"))
{
ps.setInt(1, getId());
@@ -1207,7 +1207,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreSkills()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT skill_id,skill_level,sub_pledge_id FROM clan_skills WHERE clan_id=?"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -1331,7 +1331,7 @@ public class L2Clan implements IIdentifiable, INamable
}
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
if (oldSkill != null)
{
@@ -1775,7 +1775,7 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreSubPledges()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT sub_pledge_id,name,leader_id FROM clan_subpledges WHERE clan_id=?"))
{
// Retrieve all subpledges of this clan from the database
@@ -1875,7 +1875,7 @@ public class L2Clan implements IIdentifiable, INamable
return null;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_subpledges (clan_id,sub_pledge_id,name,leader_id) values (?,?,?,?)"))
{
ps.setInt(1, getId());
@@ -1949,7 +1949,7 @@ public class L2Clan implements IIdentifiable, INamable
public void updateSubPledgeInDB(int pledgeType)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_subpledges SET leader_id=?, name=? WHERE clan_id=? AND sub_pledge_id=?"))
{
ps.setInt(1, getSubPledge(pledgeType).getLeaderId());
@@ -1970,20 +1970,20 @@ public class L2Clan implements IIdentifiable, INamable
private void restoreRankPrivs()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT privs,rank,party FROM clan_privs WHERE clan_id=?"))
{
// Retrieve all skills of this L2PcInstance from the database
ps.setInt(1, getId());
// _log.warning("clanPrivs restore for ClanId : "+getClanId());
try (ResultSet rset = ps.executeQuery())
try (ResultSet rs = ps.executeQuery())
{
// Go though the recordset of this SQL query
while (rset.next())
while (rs.next())
{
int rank = rset.getInt("rank");
int rank = rs.getInt("rank");
// int party = rset.getInt("party");
int privileges = rset.getInt("privs");
int privileges = rs.getInt("privs");
// Create a SubPledge object for each record
if (rank == -1)
{
@@ -2023,7 +2023,7 @@ public class L2Clan implements IIdentifiable, INamable
{
_privs.get(rank).setPrivs(privs);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE privs = ?"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -2059,7 +2059,7 @@ public class L2Clan implements IIdentifiable, INamable
{
_privs.put(rank, new RankPrivs(rank, 0, privs));
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?)"))
{
// Retrieve all skills of this L2PcInstance from the database
@@ -2183,7 +2183,7 @@ public class L2Clan implements IIdentifiable, INamable
if (storeInDb)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET auction_bid_at=? WHERE clan_id=?"))
{
ps.setInt(1, id);
@@ -2731,7 +2731,7 @@ public class L2Clan implements IIdentifiable, INamable
public void changeLevel(int level)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET clan_level = ? WHERE clan_id = ?"))
{
ps.setInt(1, level);
@@ -2777,7 +2777,7 @@ public class L2Clan implements IIdentifiable, INamable
setCrestId(crestId);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?"))
{
ps.setInt(1, crestId);
@@ -2814,7 +2814,7 @@ public class L2Clan implements IIdentifiable, INamable
allyId = getAllyId();
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(sqlStatement))
{
ps.setInt(1, crestId);
@@ -2860,7 +2860,7 @@ public class L2Clan implements IIdentifiable, INamable
setCrestLargeId(crestId);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_large_id = ? WHERE clan_id = ?"))
{
ps.setInt(1, crestId);

View File

@@ -25,7 +25,7 @@ import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.instancemanager.SiegeManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -266,7 +266,7 @@ public class L2ClanMember
*/
public void updatePledgeType()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET subpledge=? WHERE charId=?"))
{
ps.setLong(1, _pledgeType);
@@ -315,7 +315,7 @@ public class L2ClanMember
*/
public void updatePowerGrade()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET power_grade=? WHERE charId=?"))
{
ps.setLong(1, _powerGrade);
@@ -744,7 +744,7 @@ public class L2ClanMember
*/
public void saveApprenticeAndSponsor(int apprentice, int sponsor)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE characters SET apprentice=?,sponsor=? WHERE charId=?"))
{
ps.setInt(1, apprentice);

View File

@@ -26,7 +26,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
@@ -59,17 +59,17 @@ public class L2ContactList
{
_contacts.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_LOAD))
{
statement.setInt(1, activeChar.getObjectId());
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, activeChar.getObjectId());
try (ResultSet rs = ps.executeQuery())
{
int contactId;
String contactName;
while (rset.next())
while (rs.next())
{
contactId = rset.getInt(1);
contactId = rs.getInt(1);
contactName = CharNameTable.getInstance().getNameById(contactId);
if ((contactName == null) || contactName.equals(activeChar.getName()) || (contactId == activeChar.getObjectId()))
{
@@ -125,12 +125,12 @@ public class L2ContactList
}
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_ADD))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_ADD))
{
statement.setInt(1, activeChar.getObjectId());
statement.setInt(2, contactId);
statement.execute();
ps.setInt(1, activeChar.getObjectId());
ps.setInt(2, contactId);
ps.execute();
_contacts.add(name);
@@ -162,12 +162,12 @@ public class L2ContactList
_contacts.remove(name);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(QUERY_REMOVE))
{
statement.setInt(1, activeChar.getObjectId());
statement.setInt(2, contactId);
statement.execute();
ps.setInt(1, activeChar.getObjectId());
ps.setInt(2, contactId);
ps.execute();
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_WAS_SUCCESSFULLY_DELETED_FROM_YOUR_CONTACT_LIST);
sm.addString(name);

View File

@@ -24,7 +24,7 @@ import java.sql.ResultSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
@@ -51,17 +51,17 @@ public class L2Mentee
L2PcInstance player = getPlayerInstance();
if (player == null) // Only if player is offline
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
{
statement.setInt(1, getObjectId());
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, getObjectId());
try (ResultSet rs = ps.executeQuery())
{
if (rset.next())
if (rs.next())
{
_name = rset.getString("char_name");
_classId = rset.getInt("base_class");
_currentLevel = rset.getInt("level");
_name = rs.getString("char_name");
_classId = rs.getInt("base_class");
_currentLevel = rs.getInt("level");
}
}
}

View File

@@ -31,7 +31,7 @@ import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.enums.MacroType;
import com.l2jserver.gameserver.enums.MacroUpdateType;
import com.l2jserver.gameserver.enums.ShortcutType;
@@ -127,7 +127,7 @@ public class MacroList implements IRestorable
private void registerMacroInDb(Macro macro)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
{
ps.setInt(1, _owner.getObjectId());
@@ -163,7 +163,7 @@ public class MacroList implements IRestorable
private void deleteMacroFromDb(Macro macro)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
{
ps.setInt(1, _owner.getObjectId());
@@ -180,7 +180,7 @@ public class MacroList implements IRestorable
public boolean restoreMe()
{
_macroses.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
{
ps.setInt(1, _owner.getObjectId());

View File

@@ -26,7 +26,7 @@ import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.enums.ShortcutType;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.interfaces.IRestorable;
@@ -91,17 +91,17 @@ public class ShortCuts implements IRestorable
deleteShortCutFromDb(oldShortCut);
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,class_index) values(?,?,?,?,?,?,?)"))
{
statement.setInt(1, _owner.getObjectId());
statement.setInt(2, shortcut.getSlot());
statement.setInt(3, shortcut.getPage());
statement.setInt(4, shortcut.getType().ordinal());
statement.setInt(5, shortcut.getId());
statement.setInt(6, shortcut.getLevel());
statement.setInt(7, _owner.getClassIndex());
statement.execute();
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, shortcut.getSlot());
ps.setInt(3, shortcut.getPage());
ps.setInt(4, shortcut.getType().ordinal());
ps.setInt(5, shortcut.getId());
ps.setInt(6, shortcut.getLevel());
ps.setInt(7, _owner.getClassIndex());
ps.execute();
}
catch (Exception e)
{
@@ -159,14 +159,14 @@ public class ShortCuts implements IRestorable
*/
private void deleteShortCutFromDb(Shortcut shortcut)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
{
statement.setInt(1, _owner.getObjectId());
statement.setInt(2, shortcut.getSlot());
statement.setInt(3, shortcut.getPage());
statement.setInt(4, _owner.getClassIndex());
statement.execute();
ps.setInt(1, _owner.getObjectId());
ps.setInt(2, shortcut.getSlot());
ps.setInt(3, shortcut.getPage());
ps.setInt(4, _owner.getClassIndex());
ps.execute();
}
catch (Exception e)
{
@@ -178,7 +178,7 @@ public class ShortCuts implements IRestorable
public boolean restoreMe()
{
_shortCuts.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level FROM character_shortcuts WHERE charId=? AND class_index=?"))
{
statement.setInt(1, _owner.getObjectId());

View File

@@ -27,7 +27,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.xml.impl.UIData;
/**
@@ -95,6 +95,7 @@ public class UIKeysSettings
return;
}
// TODO(Zoey76): Refactor this to use batch.
query = "REPLACE INTO character_ui_categories (`charId`, `catId`, `order`, `cmdId`) VALUES ";
for (int category : _storedCategories.keySet())
{
@@ -105,7 +106,7 @@ public class UIKeysSettings
}
}
query = query.substring(0, query.length() - 1) + "; ";
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
@@ -126,7 +127,7 @@ public class UIKeysSettings
}
query = query.substring(0, query.length() - 1) + ";";
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
{
statement.execute();
@@ -147,11 +148,11 @@ public class UIKeysSettings
_storedCategories = new HashMap<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
ps.setInt(1, _playerObjId);
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
@@ -179,11 +180,11 @@ public class UIKeysSettings
_storedKeys = new HashMap<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
{
stmt.setInt(1, _playerObjId);
try (ResultSet rs = stmt.executeQuery())
ps.setInt(1, _playerObjId);
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{

View File

@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
@@ -795,11 +795,11 @@ public class L2PetInstance extends L2Summon
}
// pet control item no longer exists, delete the pet from the db
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
{
statement.setInt(1, getControlObjectId());
statement.execute();
ps.setInt(1, getControlObjectId());
ps.execute();
}
catch (Exception e)
{
@@ -851,14 +851,14 @@ public class L2PetInstance extends L2Summon
private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
{
L2PetInstance pet;
statement.setInt(1, control.getObjectId());
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, control.getObjectId());
try (ResultSet rs = ps.executeQuery())
{
if (!rset.next())
if (!rs.next())
{
if (template.isType("L2BabyPet"))
{
@@ -873,17 +873,17 @@ public class L2PetInstance extends L2Summon
if (template.isType("L2BabyPet"))
{
pet = new L2BabyPetInstance(template, owner, control, rset.getByte("level"));
pet = new L2BabyPetInstance(template, owner, control, rs.getByte("level"));
}
else
{
pet = new L2PetInstance(template, owner, control, rset.getByte("level"));
pet = new L2PetInstance(template, owner, control, rs.getByte("level"));
}
pet._respawned = true;
pet.setName(rset.getString("name"));
pet.setName(rs.getString("name"));
long exp = rset.getLong("exp");
long exp = rs.getLong("exp");
L2PetLevelData info = PetDataTable.getInstance().getPetLevelData(pet.getId(), pet.getLevel());
// DS: update experience based by level
// Avoiding pet delevels due to exp per level values changed.
@@ -893,18 +893,18 @@ public class L2PetInstance extends L2Summon
}
pet.getStat().setExp(exp);
pet.getStat().setSp(rset.getInt("sp"));
pet.getStat().setSp(rs.getInt("sp"));
pet.getStatus().setCurrentHp(rset.getInt("curHp"));
pet.getStatus().setCurrentMp(rset.getInt("curMp"));
pet.getStatus().setCurrentHp(rs.getInt("curHp"));
pet.getStatus().setCurrentMp(rs.getInt("curMp"));
pet.getStatus().setCurrentCp(pet.getMaxCp());
if (rset.getDouble("curHp") < 1)
if (rs.getDouble("curHp") < 1)
{
pet.setIsDead(true);
pet.stopHpMpRegeneration();
}
pet.setCurrentFed(rset.getInt("fed"));
pet.setCurrentFed(rs.getInt("fed"));
}
return pet;
}
@@ -952,20 +952,20 @@ public class L2PetInstance extends L2Summon
req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? " + "WHERE item_obj_id = ?";
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(req))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(req))
{
statement.setString(1, getName());
statement.setInt(2, getStat().getLevel());
statement.setDouble(3, getStatus().getCurrentHp());
statement.setDouble(4, getStatus().getCurrentMp());
statement.setLong(5, getStat().getExp());
statement.setLong(6, getStat().getSp());
statement.setInt(7, getCurrentFed());
statement.setInt(8, getOwner().getObjectId());
statement.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
statement.setInt(10, getControlObjectId());
statement.executeUpdate();
ps.setString(1, getName());
ps.setInt(2, getStat().getLevel());
ps.setDouble(3, getStatus().getCurrentHp());
ps.setDouble(4, getStatus().getCurrentMp());
ps.setLong(5, getStat().getExp());
ps.setLong(6, getStat().getSp());
ps.setInt(7, getCurrentFed());
ps.setInt(8, getOwner().getObjectId());
ps.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
ps.setInt(10, getControlObjectId());
ps.executeUpdate();
_respawned = true;
@@ -1002,7 +1002,7 @@ public class L2PetInstance extends L2Summon
// Clear list for overwrite
SummonEffectsTable.getInstance().clearPetEffects(getControlObjectId());
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
{
@@ -1069,20 +1069,20 @@ public class L2PetInstance extends L2Summon
@Override
public void restoreEffects()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
{
if (!SummonEffectsTable.getInstance().containsPetId(getControlObjectId()))
{
ps1.setInt(1, getControlObjectId());
try (ResultSet rset = ps1.executeQuery())
try (ResultSet rs = ps1.executeQuery())
{
while (rset.next())
while (rs.next())
{
int effectCurTime = rset.getInt("remaining_time");
int effectCurTime = rs.getInt("remaining_time");
final Skill skill = SkillData.getInstance().getSkill(rset.getInt("skill_id"), rset.getInt("skill_level"));
final Skill skill = SkillData.getInstance().getSkill(rs.getInt("skill_id"), rs.getInt("skill_level"));
if (skill == null)
{
continue;

View File

@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.data.sql.impl.CharSummonTable;
@@ -260,14 +260,14 @@ public class L2ServitorInstance extends L2Summon implements Runnable
// Clear list for overwrite
SummonEffectsTable.getInstance().clearServitorEffects(getOwner(), getReferenceSkill());
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_SKILL_SAVE))
{
// Delete all current stored effects for summon to avoid dupe
statement.setInt(1, getOwner().getObjectId());
statement.setInt(2, getOwner().getClassIndex());
statement.setInt(3, getReferenceSkill());
statement.execute();
ps.setInt(1, getOwner().getObjectId());
ps.setInt(2, getOwner().getClassIndex());
ps.setInt(3, getReferenceSkill());
ps.execute();
int buff_index = 0;
@@ -338,22 +338,22 @@ public class L2ServitorInstance extends L2Summon implements Runnable
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
if (!SummonEffectsTable.getInstance().containsSkill(getOwner(), getReferenceSkill()))
{
try (PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
try (PreparedStatement ps = con.prepareStatement(RESTORE_SKILL_SAVE))
{
statement.setInt(1, getOwner().getObjectId());
statement.setInt(2, getOwner().getClassIndex());
statement.setInt(3, getReferenceSkill());
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, getOwner().getObjectId());
ps.setInt(2, getOwner().getClassIndex());
ps.setInt(3, getReferenceSkill());
try (ResultSet rs = ps.executeQuery())
{
while (rset.next())
while (rs.next())
{
int effectCurTime = rset.getInt("remaining_time");
int effectCurTime = rs.getInt("remaining_time");
final Skill skill = SkillData.getInstance().getSkill(rset.getInt("skill_id"), rset.getInt("skill_level"));
final Skill skill = SkillData.getInstance().getSkill(rs.getInt("skill_id"), rs.getInt("skill_level"));
if (skill == null)
{
continue;

View File

@@ -26,7 +26,7 @@ import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
/**
* @author UnAfraid
@@ -110,14 +110,14 @@ public class Announcement implements IAnnouncement
@Override
public boolean storeMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{
st.setInt(1, _type.ordinal());
st.setString(2, _content);
st.setString(3, _author);
st.execute();
try (ResultSet rset = st.getGeneratedKeys())
ps.setInt(1, _type.ordinal());
ps.setString(2, _content);
ps.setString(3, _author);
ps.execute();
try (ResultSet rset = ps.getGeneratedKeys())
{
if (rset.next())
{
@@ -136,14 +136,14 @@ public class Announcement implements IAnnouncement
@Override
public boolean updateMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{
st.setInt(1, _type.ordinal());
st.setString(2, _content);
st.setString(3, _author);
st.setInt(4, _id);
st.execute();
ps.setInt(1, _type.ordinal());
ps.setString(2, _content);
ps.setString(3, _author);
ps.setInt(4, _id);
ps.execute();
}
catch (Exception e)
{
@@ -156,11 +156,11 @@ public class Announcement implements IAnnouncement
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(DELETE_QUERY))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
{
st.setInt(1, _id);
st.execute();
ps.setInt(1, _id);
ps.execute();
}
catch (Exception e)
{

View File

@@ -27,7 +27,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.util.Broadcast;
@@ -96,17 +96,17 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override
public boolean storeMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{
st.setInt(1, getType().ordinal());
st.setString(2, getContent());
st.setString(3, getAuthor());
st.setLong(4, getInitial());
st.setLong(5, getDelay());
st.setInt(6, getRepeat());
st.execute();
try (ResultSet rset = st.getGeneratedKeys())
ps.setInt(1, getType().ordinal());
ps.setString(2, getContent());
ps.setString(3, getAuthor());
ps.setLong(4, getInitial());
ps.setLong(5, getDelay());
ps.setInt(6, getRepeat());
ps.execute();
try (ResultSet rset = ps.getGeneratedKeys())
{
if (rset.next())
{
@@ -125,17 +125,17 @@ public final class AutoAnnouncement extends Announcement implements Runnable
@Override
public boolean updateMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{
st.setInt(1, getType().ordinal());
st.setString(2, getContent());
st.setString(3, getAuthor());
st.setLong(4, getInitial());
st.setLong(5, getDelay());
st.setLong(6, getRepeat());
st.setLong(7, getId());
st.execute();
ps.setInt(1, getType().ordinal());
ps.setString(2, getContent());
ps.setString(3, getAuthor());
ps.setLong(4, getInitial());
ps.setLong(5, getDelay());
ps.setLong(6, getRepeat());
ps.setLong(7, getId());
ps.execute();
}
catch (Exception e)
{

View File

@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.items.L2Item;
@@ -161,25 +161,25 @@ public final class Product
private void save()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO `buylists`(`buylist_id`, `item_id`, `count`, `next_restock_time`) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE `count` = ?, `next_restock_time` = ?"))
{
statement.setInt(1, getBuyListId());
statement.setInt(2, getItemId());
statement.setLong(3, getCount());
statement.setLong(5, getCount());
ps.setInt(1, getBuyListId());
ps.setInt(2, getItemId());
ps.setLong(3, getCount());
ps.setLong(5, getCount());
if ((_restockTask != null) && (_restockTask.getDelay(TimeUnit.MILLISECONDS) > 0))
{
long nextRestockTime = System.currentTimeMillis() + _restockTask.getDelay(TimeUnit.MILLISECONDS);
statement.setLong(4, nextRestockTime);
statement.setLong(6, nextRestockTime);
ps.setLong(4, nextRestockTime);
ps.setLong(6, nextRestockTime);
}
else
{
statement.setLong(4, 0);
statement.setLong(6, 0);
ps.setLong(4, 0);
ps.setLong(6, 0);
}
statement.executeUpdate();
ps.executeUpdate();
}
catch (Exception e)
{

View File

@@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.enums.AuctionItemType;
@@ -164,11 +164,11 @@ public class Auction
/** Load auctions */
private void load()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("Select * from auction where id = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("Select * from auction where id = ?"))
{
statement.setInt(1, getId());
try (ResultSet rs = statement.executeQuery())
ps.setInt(1, getId());
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
@@ -199,11 +199,11 @@ public class Auction
_highestBidderName = "";
_highestBidderMaxBid = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT bidderId, bidderName, maxBid, clan_name, time_bid FROM auction_bid WHERE auctionId = ? ORDER BY maxBid DESC"))
{
statement.setInt(1, getId());
try (ResultSet rs = statement.executeQuery())
ps.setInt(1, getId());
try (ResultSet rs = ps.executeQuery())
{
while (rs.next())
{
@@ -248,12 +248,12 @@ public class Auction
/** Save Auction Data End */
private void saveAuctionDate()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("Update auction set endDate = ? where id = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("Update auction set endDate = ? where id = ?"))
{
statement.setLong(1, _endDate);
statement.setInt(2, _id);
statement.execute();
ps.setLong(1, _endDate);
ps.setInt(2, _id);
ps.execute();
}
catch (Exception e)
{
@@ -346,33 +346,33 @@ public class Auction
*/
private void updateInDB(L2PcInstance bidder, long bid)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
if (_bidders.get(bidder.getClanId()) != null)
{
try (PreparedStatement statement = con.prepareStatement("UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?"))
try (PreparedStatement ps = con.prepareStatement("UPDATE auction_bid SET bidderId=?, bidderName=?, maxBid=?, time_bid=? WHERE auctionId=? AND bidderId=?"))
{
statement.setInt(1, bidder.getClanId());
statement.setString(2, bidder.getClan().getLeaderName());
statement.setLong(3, bid);
statement.setLong(4, System.currentTimeMillis());
statement.setInt(5, getId());
statement.setInt(6, bidder.getClanId());
statement.execute();
ps.setInt(1, bidder.getClanId());
ps.setString(2, bidder.getClan().getLeaderName());
ps.setLong(3, bid);
ps.setLong(4, System.currentTimeMillis());
ps.setInt(5, getId());
ps.setInt(6, bidder.getClanId());
ps.execute();
}
}
else
{
try (PreparedStatement statement = con.prepareStatement("INSERT INTO auction_bid (id, auctionId, bidderId, bidderName, maxBid, clan_name, time_bid) VALUES (?, ?, ?, ?, ?, ?, ?)"))
try (PreparedStatement ps = con.prepareStatement("INSERT INTO auction_bid (id, auctionId, bidderId, bidderName, maxBid, clan_name, time_bid) VALUES (?, ?, ?, ?, ?, ?, ?)"))
{
statement.setInt(1, IdFactory.getInstance().getNextId());
statement.setInt(2, getId());
statement.setInt(3, bidder.getClanId());
statement.setString(4, bidder.getName());
statement.setLong(5, bid);
statement.setString(6, bidder.getClan().getName());
statement.setLong(7, System.currentTimeMillis());
statement.execute();
ps.setInt(1, IdFactory.getInstance().getNextId());
ps.setInt(2, getId());
ps.setInt(3, bidder.getClanId());
ps.setString(4, bidder.getName());
ps.setLong(5, bid);
ps.setString(6, bidder.getClan().getName());
ps.setLong(7, System.currentTimeMillis());
ps.execute();
}
if (L2World.getInstance().getPlayer(_highestBidderName) != null)
{
@@ -403,11 +403,11 @@ public class Auction
/** Remove bids */
private void removeBids()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=?"))
{
statement.setInt(1, getId());
statement.execute();
ps.setInt(1, getId());
ps.execute();
}
catch (Exception e)
{
@@ -436,11 +436,11 @@ public class Auction
public void deleteAuctionFromDB()
{
ClanHallAuctionManager.getInstance().getAuctions().remove(this);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction WHERE itemId=?"))
{
statement.setInt(1, _itemId);
statement.execute();
ps.setInt(1, _itemId);
ps.execute();
}
catch (Exception e)
{
@@ -492,12 +492,12 @@ public class Auction
*/
public synchronized void cancelBid(int bidder)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM auction_bid WHERE auctionId=? AND bidderId=?"))
{
statement.setInt(1, getId());
statement.setInt(2, bidder);
statement.execute();
ps.setInt(1, getId());
ps.setInt(2, bidder);
ps.execute();
}
catch (Exception e)
{
@@ -521,23 +521,23 @@ public class Auction
public void confirmAuction()
{
ClanHallAuctionManager.getInstance().getAuctions().add(this);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO auction (id, sellerId, sellerName, sellerClanName, itemType, itemId, itemObjectId, itemName, itemQuantity, startingBid, currentBid, endDate) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, getId());
statement.setInt(2, _sellerId);
statement.setString(3, _sellerName);
statement.setString(4, _sellerClanName);
statement.setString(5, _itemType);
statement.setInt(6, _itemId);
statement.setInt(7, _itemObjectId);
statement.setString(8, _itemName);
statement.setLong(9, _itemQuantity);
statement.setLong(10, _startingBid);
statement.setLong(11, _currentBid);
statement.setLong(12, _endDate);
statement.execute();
statement.close();
ps.setInt(1, getId());
ps.setInt(2, _sellerId);
ps.setString(3, _sellerName);
ps.setString(4, _sellerClanName);
ps.setString(5, _itemType);
ps.setInt(6, _itemId);
ps.setInt(7, _itemObjectId);
ps.setString(8, _itemName);
ps.setLong(9, _itemQuantity);
ps.setLong(10, _startingBid);
ps.setLong(11, _currentBid);
ps.setLong(12, _endDate);
ps.execute();
ps.close();
}
catch (Exception e)
{

View File

@@ -31,7 +31,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.data.xml.impl.CastleData;
@@ -221,7 +221,7 @@ public final class Castle extends AbstractResidence
public void dbSave()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
{
ps.setInt(1, getResidenceId());
@@ -362,7 +362,7 @@ public final class Castle extends AbstractResidence
}
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
{
ps.setLong(1, getTreasury());
@@ -624,7 +624,7 @@ public final class Castle extends AbstractResidence
@Override
protected void load()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
{
@@ -671,7 +671,7 @@ public final class Castle extends AbstractResidence
/** Load All Functions */
private void loadFunctions()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?"))
{
ps.setInt(1, getResidenceId());
@@ -696,7 +696,7 @@ public final class Castle extends AbstractResidence
public void removeFunction(int functionType)
{
_function.remove(functionType);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?"))
{
ps.setInt(1, getResidenceId());
@@ -771,7 +771,7 @@ public final class Castle extends AbstractResidence
// This method loads castle door upgrade data from database
private void loadDoorUpgrade()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
{
ps.setInt(1, getResidenceId());
@@ -797,7 +797,7 @@ public final class Castle extends AbstractResidence
door.setCurrentHp(door.getCurrentHp());
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?"))
{
ps.setInt(1, getResidenceId());
@@ -822,7 +822,7 @@ public final class Castle extends AbstractResidence
if (save)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)"))
{
ps.setInt(1, doorId);
@@ -849,7 +849,7 @@ public final class Castle extends AbstractResidence
CastleManorManager.getInstance().resetManorData(getResidenceId());
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Need to remove has castle flag from clan_data, should be checked from castle table.
try (PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET hasCastle = 0 WHERE hasCastle = ?"))
@@ -1022,7 +1022,7 @@ public final class Castle extends AbstractResidence
public void updateShowNpcCrest()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
{
ps.setString(1, String.valueOf(getShowNpcCrest()));
@@ -1066,7 +1066,7 @@ public final class Castle extends AbstractResidence
{
_ticketBuyCount = count;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
{
ps.setInt(1, _ticketBuyCount);
@@ -1089,7 +1089,7 @@ public final class Castle extends AbstractResidence
{
if (save)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)"))
{
ps.setInt(1, getResidenceId());
@@ -1116,7 +1116,7 @@ public final class Castle extends AbstractResidence
ts.setUpgradeLevel(0);
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
{
ps.setInt(1, getResidenceId());
@@ -1206,7 +1206,7 @@ public final class Castle extends AbstractResidence
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
{
ps.setString(1, side.toString());

View File

@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.model.L2Clan;
@@ -187,7 +187,7 @@ public abstract class ClanHall
public void dbSave()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO clanhall_functions (hall_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
{
ps.setInt(1, getId());
@@ -445,7 +445,7 @@ public abstract class ClanHall
/** Load All Functions */
protected void loadFunctions()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM clanhall_functions WHERE hall_id = ?"))
{
ps.setInt(1, getId());
@@ -470,7 +470,7 @@ public abstract class ClanHall
public void removeFunction(int functionType)
{
_functions.remove(functionType);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_functions WHERE hall_id=? AND type=?"))
{
ps.setInt(1, getId());

View File

@@ -25,7 +25,7 @@ import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -47,7 +47,7 @@ public class Couple
{
_Id = coupleId;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
{
ps.setInt(1, _Id);
@@ -87,7 +87,7 @@ public class Couple
_weddingDate = Calendar.getInstance();
_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
{
_Id = IdFactory.getInstance().getNextId();
@@ -107,7 +107,7 @@ public class Couple
public void marry()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?"))
{
ps.setBoolean(1, true);
@@ -125,7 +125,7 @@ public class Couple
public void divorce()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?"))
{
ps.setInt(1, _Id);

View File

@@ -36,7 +36,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.FortUpdater;
import com.l2jserver.gameserver.FortUpdater.UpdaterType;
import com.l2jserver.gameserver.ThreadPoolManager;
@@ -221,7 +221,7 @@ public final class Fort extends AbstractResidence
public void dbSave()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
{
ps.setInt(1, getResidenceId());
@@ -494,7 +494,7 @@ public final class Fort extends AbstractResidence
public void saveFortVariables()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
{
ps.setInt(1, _supplyLvL);
@@ -561,7 +561,7 @@ public final class Fort extends AbstractResidence
@Override
protected void load()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
{
ps.setInt(1, getResidenceId());
@@ -623,7 +623,7 @@ public final class Fort extends AbstractResidence
/** Load All Functions */
private void loadFunctions()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?"))
{
ps.setInt(1, getResidenceId());
@@ -648,7 +648,7 @@ public final class Fort extends AbstractResidence
public void removeFunction(int functionType)
{
_function.remove(functionType);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?"))
{
ps.setInt(1, getResidenceId());
@@ -750,7 +750,7 @@ public final class Fort extends AbstractResidence
// This method loads fort door upgrade data from database
private void loadDoorUpgrade()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
{
ps.setInt(1, getResidenceId());
@@ -770,7 +770,7 @@ public final class Fort extends AbstractResidence
private void removeDoorUpgrade()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
{
ps.setInt(1, getResidenceId());
@@ -784,7 +784,7 @@ public final class Fort extends AbstractResidence
private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
{
ps.setInt(1, doorId);
@@ -813,7 +813,7 @@ public final class Fort extends AbstractResidence
_lastOwnedTime.setTimeInMillis(0);
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?"))
{
ps.setInt(1, clanId);
@@ -1025,7 +1025,7 @@ public final class Fort extends AbstractResidence
{
_state = state;
_castleId = castleId;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
{
ps.setInt(1, getFortState());
@@ -1157,7 +1157,7 @@ public final class Fort extends AbstractResidence
private void initNpcs()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?"))
{
ps.setInt(1, getResidenceId());
@@ -1188,7 +1188,7 @@ public final class Fort extends AbstractResidence
private void initSiegeNpcs()
{
_siegeNpcs.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
{
ps.setInt(1, getResidenceId());
@@ -1217,7 +1217,7 @@ public final class Fort extends AbstractResidence
private void initNpcCommanders()
{
_npcCommanders.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
{
ps.setInt(1, getResidenceId());
@@ -1249,7 +1249,7 @@ public final class Fort extends AbstractResidence
_specialEnvoys.clear();
_envoyCastles.clear();
_availableCastles.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT id, npcId, x, y, z, heading, castleId FROM fort_spawnlist WHERE fortId = ? AND spawnType = ? ORDER BY id"))
{
ps.setInt(1, getResidenceId());

View File

@@ -30,7 +30,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.enums.ChatType;
@@ -495,7 +495,7 @@ public class FortSiege implements Siegable
/** Clear all registered siege clans from database for fort */
public void clearSiegeClan()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?"))
{
ps.setInt(1, getFort().getResidenceId());
@@ -762,15 +762,15 @@ public class FortSiege implements Siegable
private void removeSiegeClan(int clanId)
{
final String query = (clanId != 0) ? DELETE_FORT_SIEGECLANS_BY_CLAN_ID : DELETE_FORT_SIEGECLANS;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(query))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
statement.setInt(1, getFort().getResidenceId());
ps.setInt(1, getFort().getResidenceId());
if (clanId != 0)
{
statement.setInt(2, clanId);
ps.setInt(2, clanId);
}
statement.execute();
ps.execute();
loadSiegeClan();
if (getAttackerClans().isEmpty())
@@ -970,7 +970,7 @@ public class FortSiege implements Siegable
private void loadSiegeClan()
{
getAttackerClans().clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?"))
{
ps.setInt(1, getFort().getResidenceId());
@@ -1031,7 +1031,7 @@ public class FortSiege implements Siegable
/** Save siege date to database. */
private void saveSiegeDate()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?"))
{
ps.setLong(1, getSiegeDate().getTimeInMillis());
@@ -1055,12 +1055,12 @@ public class FortSiege implements Siegable
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
{
statement.setInt(1, clan.getId());
statement.setInt(2, getFort().getResidenceId());
statement.execute();
ps.setInt(1, clan.getId());
ps.setInt(2, getFort().getResidenceId());
ps.execute();
addAttacker(clan.getId());
}

View File

@@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
@@ -110,7 +110,7 @@ public class Hero
HERO_DIARY.clear();
HERO_MESSAGE.clear();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s1 = con.createStatement();
ResultSet rset = s1.executeQuery(GET_HEROES);
PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
@@ -208,11 +208,11 @@ public class Hero
*/
public void loadMessage(int charId)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
{
statement.setInt(1, charId);
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, charId);
try (ResultSet rset = ps.executeQuery())
{
if (rset.next())
{
@@ -230,11 +230,11 @@ public class Hero
{
final List<StatsSet> diary = new ArrayList<>();
int diaryentries = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
{
statement.setInt(1, charId);
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, charId);
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{
@@ -297,13 +297,13 @@ public class Hero
int _losses = 0;
int _draws = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
{
statement.setInt(1, charId);
statement.setInt(2, charId);
statement.setLong(3, from);
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, charId);
ps.setInt(2, charId);
ps.setLong(3, from);
try (ResultSet rset = ps.executeQuery())
{
int charOneId;
int charOneClass;
@@ -694,13 +694,13 @@ public class Hero
public void updateHeroes(boolean setDefault)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
if (setDefault)
{
try (PreparedStatement update_all = con.prepareStatement(UPDATE_ALL))
try (Statement s = con.createStatement())
{
update_all.execute();
s.executeUpdate(UPDATE_ALL);
}
}
else
@@ -825,14 +825,14 @@ public class Hero
public void setDiaryData(int charId, int action, int param)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
{
statement.setInt(1, charId);
statement.setLong(2, System.currentTimeMillis());
statement.setInt(3, action);
statement.setInt(4, param);
statement.execute();
ps.setInt(1, charId);
ps.setLong(2, System.currentTimeMillis());
ps.setInt(3, action);
ps.setInt(4, param);
ps.execute();
}
catch (SQLException e)
{
@@ -861,12 +861,12 @@ public class Hero
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
{
statement.setString(1, HERO_MESSAGE.get(charId));
statement.setInt(2, charId);
statement.execute();
ps.setString(1, HERO_MESSAGE.get(charId));
ps.setInt(2, charId);
ps.execute();
}
catch (SQLException e)
{
@@ -876,10 +876,10 @@ public class Hero
private void deleteItemsInDb()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_ITEMS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
statement.execute();
s.executeUpdate(DELETE_ITEMS);
}
catch (SQLException e)
{

View File

@@ -33,7 +33,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.data.xml.impl.SiegeScheduleData;
@@ -773,11 +773,11 @@ public class Siege implements Siegable
/** Clear all registered siege clans from database for castle */
public void clearSiegeClan()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
{
statement.setInt(1, getCastle().getResidenceId());
statement.execute();
ps.setInt(1, getCastle().getResidenceId());
ps.execute();
if (getCastle().getOwnerId() > 0)
{
@@ -801,11 +801,11 @@ public class Siege implements Siegable
/** Clear all siege clans waiting for approval from database for castle */
public void clearSiegeWaitingClan()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
{
statement.setInt(1, getCastle().getResidenceId());
statement.execute();
ps.setInt(1, getCastle().getResidenceId());
ps.execute();
getDefenderWaitingClans().clear();
}
@@ -1028,12 +1028,12 @@ public class Siege implements Siegable
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
{
statement.setInt(1, getCastle().getResidenceId());
statement.setInt(2, clanId);
statement.execute();
ps.setInt(1, getCastle().getResidenceId());
ps.setInt(2, clanId);
ps.execute();
loadSiegeClan();
}
@@ -1294,8 +1294,8 @@ public class Siege implements Siegable
private void loadSiegeClan()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
{
getAttackerClans().clear();
getDefenderClans().clear();
@@ -1307,8 +1307,8 @@ public class Siege implements Siegable
addDefender(getCastle().getOwnerId(), SiegeClanType.OWNER);
}
statement.setInt(1, getCastle().getResidenceId());
try (ResultSet rs = statement.executeQuery())
ps.setInt(1, getCastle().getResidenceId());
try (ResultSet rs = ps.executeQuery())
{
int typeId;
while (rs.next())
@@ -1405,14 +1405,14 @@ public class Siege implements Siegable
_scheduledStartSiegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new Siege.ScheduleStartSiegeTask(getCastle()), 1000);
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
{
statement.setLong(1, getSiegeDate().getTimeInMillis());
statement.setLong(2, getTimeRegistrationOverDate().getTimeInMillis());
statement.setString(3, String.valueOf(getIsTimeRegistrationOver()));
statement.setInt(4, getCastle().getResidenceId());
statement.execute();
ps.setLong(1, getSiegeDate().getTimeInMillis());
ps.setLong(2, getTimeRegistrationOverDate().getTimeInMillis());
ps.setString(3, String.valueOf(getIsTimeRegistrationOver()));
ps.setInt(4, getCastle().getResidenceId());
ps.execute();
}
catch (Exception e)
{
@@ -1434,7 +1434,7 @@ public class Siege implements Siegable
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
{
@@ -1453,22 +1453,22 @@ public class Siege implements Siegable
if (!isUpdateRegistration)
{
try (PreparedStatement statement = con.prepareStatement("INSERT INTO siege_clans (clan_id,castle_id,type,castle_owner) values (?,?,?,0)"))
try (PreparedStatement ps = con.prepareStatement("INSERT INTO siege_clans (clan_id,castle_id,type,castle_owner) values (?,?,?,0)"))
{
statement.setInt(1, clan.getId());
statement.setInt(2, getCastle().getResidenceId());
statement.setInt(3, typeId);
statement.execute();
ps.setInt(1, clan.getId());
ps.setInt(2, getCastle().getResidenceId());
ps.setInt(3, typeId);
ps.execute();
}
}
else
{
try (PreparedStatement statement = con.prepareStatement("UPDATE siege_clans SET type = ? WHERE castle_id = ? AND clan_id = ?"))
try (PreparedStatement ps = con.prepareStatement("UPDATE siege_clans SET type = ? WHERE castle_id = ? AND clan_id = ?"))
{
statement.setInt(1, typeId);
statement.setInt(2, getCastle().getResidenceId());
statement.setInt(3, clan.getId());
statement.execute();
ps.setInt(1, typeId);
ps.setInt(2, getCastle().getResidenceId());
ps.setInt(3, clan.getId());
ps.execute();
}
}

View File

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.instancemanager.ClanHallAuctionManager;
@@ -218,14 +218,14 @@ public final class AuctionableHall extends ClanHall
@Override
public final void updateDb()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE clanhall SET ownerId=?, paidUntil=?, paid=? WHERE id=?"))
{
statement.setInt(1, getOwnerId());
statement.setLong(2, getPaidUntil());
statement.setInt(3, (getPaid()) ? 1 : 0);
statement.setInt(4, getId());
statement.execute();
ps.setInt(1, getOwnerId());
ps.setLong(2, getPaidUntil());
ps.setInt(3, (getPaid()) ? 1 : 0);
ps.setInt(4, getId());
ps.execute();
}
catch (Exception e)
{

View File

@@ -30,7 +30,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
import com.l2jserver.gameserver.enums.ChatType;
@@ -93,11 +93,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
public void loadAttackers()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(SQL_LOAD_ATTACKERS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_ATTACKERS))
{
statement.setInt(1, _hall.getId());
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, _hall.getId());
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{
@@ -115,11 +115,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
public final void saveAttackers()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement delStatement = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM clanhall_siege_attackers WHERE clanhall_id = ?"))
{
delStatement.setInt(1, _hall.getId());
delStatement.execute();
ps.setInt(1, _hall.getId());
ps.execute();
if (_attackers.size() > 0)
{
@@ -147,11 +147,11 @@ public abstract class ClanHallSiegeEngine extends Quest implements Siegable
if (_guards == null)
{
_guards = new ArrayList<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(SQL_LOAD_GUARDS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_LOAD_GUARDS))
{
statement.setInt(1, _hall.getId());
try (ResultSet rset = statement.executeQuery())
ps.setInt(1, _hall.getId());
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{

View File

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.util.Calendar;
import java.util.logging.Level;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.enums.SiegeClanType;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2SiegeClan;
@@ -132,13 +132,13 @@ public final class SiegableHall extends ClanHall
@Override
public final void updateDb()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(SQL_SAVE))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SQL_SAVE))
{
statement.setInt(1, getOwnerId());
statement.setLong(2, getNextSiegeTime());
statement.setInt(3, getId());
statement.execute();
ps.setInt(1, getOwnerId());
ps.setLong(2, getNextSiegeTime());
ps.setInt(3, getId());
ps.execute();
}
catch (Exception e)
{

View File

@@ -22,12 +22,13 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
import com.l2jserver.gameserver.model.ItemInfo;
@@ -52,7 +53,7 @@ public final class ItemAuction
private final long _startingTime;
private volatile long _endingTime;
private final AuctionItem _auctionItem;
private final ArrayList<ItemAuctionBid> _auctionBids;
private final List<ItemAuctionBid> _auctionBids;
private final Object _auctionStateLock;
private volatile ItemAuctionState _auctionState;
@@ -70,10 +71,10 @@ public final class ItemAuction
public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem)
{
this(auctionId, instanceId, startingTime, endingTime, auctionItem, new ArrayList<ItemAuctionBid>(), ItemAuctionState.CREATED);
this(auctionId, instanceId, startingTime, endingTime, auctionItem, new ArrayList<>(), ItemAuctionState.CREATED);
}
public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem, final ArrayList<ItemAuctionBid> auctionBids, final ItemAuctionState auctionState)
public ItemAuction(final int auctionId, final int instanceId, final long startingTime, final long endingTime, final AuctionItem auctionItem, final List<ItemAuctionBid> auctionBids, final ItemAuctionState auctionState)
{
_auctionId = auctionId;
_instanceId = instanceId;
@@ -193,17 +194,17 @@ public final class ItemAuction
public final void storeMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
{
statement.setInt(1, _auctionId);
statement.setInt(2, _instanceId);
statement.setInt(3, _auctionItem.getAuctionItemId());
statement.setLong(4, _startingTime);
statement.setLong(5, _endingTime);
statement.setByte(6, _auctionState.getStateId());
statement.setByte(7, _auctionState.getStateId());
statement.execute();
ps.setInt(1, _auctionId);
ps.setInt(2, _instanceId);
ps.setInt(3, _auctionItem.getAuctionItemId());
ps.setLong(4, _startingTime);
ps.setLong(5, _endingTime);
ps.setByte(6, _auctionState.getStateId());
ps.setByte(7, _auctionState.getStateId());
ps.execute();
}
catch (final SQLException e)
{
@@ -227,7 +228,7 @@ public final class ItemAuction
final void updatePlayerBidInternal(final ItemAuctionBid bid, final boolean delete)
{
final String query = delete ? DELETE_ITEM_AUCTION_BID : INSERT_ITEM_AUCTION_BID;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
ps.setInt(1, _auctionId);

View File

@@ -29,6 +29,7 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -40,7 +41,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
import com.l2jserver.gameserver.enums.ItemLocation;
@@ -163,7 +164,7 @@ public final class ItemAuctionInstance
throw new IllegalArgumentException("No items defined");
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_AUCTION_ID_BY_INSTANCE_ID))
{
ps.setInt(1, _instanceId);
@@ -544,7 +545,7 @@ public final class ItemAuctionInstance
private final ItemAuction loadAuction(final int auctionId) throws SQLException
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
int auctionItemId = 0;
long startingTime = 0;
@@ -604,7 +605,7 @@ public final class ItemAuctionInstance
return null;
}
final ArrayList<ItemAuctionBid> auctionBids = new ArrayList<>();
final List<ItemAuctionBid> auctionBids = new ArrayList<>();
try (PreparedStatement ps = con.prepareStatement(SELECT_PLAYERS_ID_BY_AUCTION_ID))
{
ps.setInt(1, auctionId);
@@ -622,4 +623,4 @@ public final class ItemAuctionInstance
return new ItemAuction(auctionId, _instanceId, startingTime, endingTime, auctionItem, auctionBids, auctionState);
}
}
}
}

View File

@@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.data.xml.impl.ArmorSetsData;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.enums.ItemLocation;
@@ -1832,13 +1832,13 @@ public abstract class Inventory extends ItemContainer
@Override
public void restore()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
{
statement.setInt(1, getOwnerId());
statement.setString(2, getBaseLocation().name());
statement.setString(3, getEquipLocation().name());
try (ResultSet inv = statement.executeQuery())
ps.setInt(1, getOwnerId());
ps.setString(2, getBaseLocation().name());
ps.setString(3, getEquipLocation().name());
try (ResultSet inv = ps.executeQuery())
{
L2ItemInstance item;
while (inv.next())

View File

@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.enums.ItemLocation;
@@ -706,12 +706,12 @@ public abstract class ItemContainer
*/
public void restore()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND (loc=?)"))
{
statement.setInt(1, getOwnerId());
statement.setString(2, getBaseLocation().name());
try (ResultSet inv = statement.executeQuery())
ps.setInt(1, getOwnerId());
ps.setString(2, getBaseLocation().name());
try (ResultSet inv = ps.executeQuery())
{
L2ItemInstance item;
while (inv.next())

View File

@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.logging.Level;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.enums.ItemLocation;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.model.L2World;
@@ -118,13 +118,13 @@ public class Mail extends ItemContainer
@Override
public void restore()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
{
statement.setInt(1, getOwnerId());
statement.setString(2, getBaseLocation().name());
statement.setInt(3, getMessageId());
try (ResultSet inv = statement.executeQuery())
ps.setInt(1, getOwnerId());
ps.setString(2, getBaseLocation().name());
ps.setInt(3, getMessageId());
try (ResultSet inv = ps.executeQuery())
{
L2ItemInstance item;
while (inv.next())

View File

@@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.enums.ItemLocation;
import com.l2jserver.gameserver.model.TradeItem;
@@ -880,11 +880,11 @@ public class PcInventory extends Inventory
public static int[][] restoreVisibleInventory(int objectId)
{
int[][] paperdoll = new int[33][4];
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement2 = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
{
statement2.setInt(1, objectId);
try (ResultSet invdata = statement2.executeQuery())
ps.setInt(1, objectId);
try (ResultSet invdata = ps.executeQuery())
{
while (invdata.next())
{

View File

@@ -34,7 +34,7 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.xml.impl.AppearanceItemData;
@@ -924,7 +924,7 @@ public final class L2ItemInstance extends L2Object
}
_augmentation = augmentation;
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
updateItemAttributes(con);
}
@@ -950,7 +950,7 @@ public final class L2ItemInstance extends L2Object
final L2Augmentation augment = _augmentation;
_augmentation = null;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?"))
{
ps.setInt(1, getObjectId());
@@ -967,7 +967,7 @@ public final class L2ItemInstance extends L2Object
public void restoreAttributes()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT augAttributes FROM item_attributes WHERE itemId=?");
PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
{
@@ -1177,7 +1177,7 @@ public final class L2ItemInstance extends L2Object
_elementals[0] = new Elementals(element, value);
}
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
updateItemElements(con);
}
@@ -1195,7 +1195,7 @@ public final class L2ItemInstance extends L2Object
public void setElementAttr(byte element, int value)
{
applyAttribute(element, value);
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
updateItemElements(con);
}
@@ -1232,7 +1232,7 @@ public final class L2ItemInstance extends L2Object
_elementals = array;
String query = (element != -1) ? "DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?" : "DELETE FROM item_elementals WHERE itemId = ?";
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
if (element != -1)
@@ -1661,7 +1661,7 @@ public final class L2ItemInstance extends L2Object
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " + "WHERE object_id = ?"))
{
ps.setInt(1, _ownerId);
@@ -1696,7 +1696,7 @@ public final class L2ItemInstance extends L2Object
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"))
{
ps.setInt(1, _ownerId);
@@ -1742,7 +1742,7 @@ public final class L2ItemInstance extends L2Object
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?"))
{

View File

@@ -24,6 +24,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
@@ -38,7 +39,7 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
@@ -177,9 +178,9 @@ public class Olympiad extends ListenersContainer
{
NOBLES.clear();
boolean loaded = false;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA);
ResultSet rset = statement.executeQuery())
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rset = s.executeQuery(OLYMPIAD_LOAD_DATA))
{
while (rset.next())
{
@@ -250,9 +251,9 @@ public class Olympiad extends ListenersContainer
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);
ResultSet rset = statement.executeQuery())
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement();
ResultSet rset = s.executeQuery(OLYMPIAD_LOAD_NOBLES))
{
StatsSet statData;
while (rset.next())
@@ -319,9 +320,9 @@ public class Olympiad extends ListenersContainer
{
NOBLES_RANK.clear();
Map<Integer, Integer> tmpPlace = new HashMap<>();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS);
ResultSet rset = statement.executeQuery())
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement statement = con.createStatement();
ResultSet rset = statement.executeQuery(GET_ALL_CLASSIFIED_NOBLESS))
{
int place = 1;
while (rset.next())
@@ -718,7 +719,7 @@ public class Olympiad extends ListenersContainer
return;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
{
@@ -742,38 +743,38 @@ public class Olympiad extends ListenersContainer
int compDoneWeekTeam = nobleInfo.getInt(COMP_DONE_WEEK_TEAM);
boolean toSave = nobleInfo.getBoolean("to_save");
try (PreparedStatement statement = con.prepareStatement(toSave ? OLYMPIAD_SAVE_NOBLES : OLYMPIAD_UPDATE_NOBLES))
try (PreparedStatement ps = con.prepareStatement(toSave ? OLYMPIAD_SAVE_NOBLES : OLYMPIAD_UPDATE_NOBLES))
{
if (toSave)
{
statement.setInt(1, charId);
statement.setInt(2, classId);
statement.setInt(3, points);
statement.setInt(4, compDone);
statement.setInt(5, compWon);
statement.setInt(6, compLost);
statement.setInt(7, compDrawn);
statement.setInt(8, compDoneWeek);
statement.setInt(9, compDoneWeekClassed);
statement.setInt(10, compDoneWeekNonClassed);
statement.setInt(11, compDoneWeekTeam);
ps.setInt(1, charId);
ps.setInt(2, classId);
ps.setInt(3, points);
ps.setInt(4, compDone);
ps.setInt(5, compWon);
ps.setInt(6, compLost);
ps.setInt(7, compDrawn);
ps.setInt(8, compDoneWeek);
ps.setInt(9, compDoneWeekClassed);
ps.setInt(10, compDoneWeekNonClassed);
ps.setInt(11, compDoneWeekTeam);
nobleInfo.set("to_save", false);
}
else
{
statement.setInt(1, points);
statement.setInt(2, compDone);
statement.setInt(3, compWon);
statement.setInt(4, compLost);
statement.setInt(5, compDrawn);
statement.setInt(6, compDoneWeek);
statement.setInt(7, compDoneWeekClassed);
statement.setInt(8, compDoneWeekNonClassed);
statement.setInt(9, compDoneWeekTeam);
statement.setInt(10, charId);
ps.setInt(1, points);
ps.setInt(2, compDone);
ps.setInt(3, compWon);
ps.setInt(4, compLost);
ps.setInt(5, compDrawn);
ps.setInt(6, compDoneWeek);
ps.setInt(7, compDoneWeekClassed);
ps.setInt(8, compDoneWeekNonClassed);
ps.setInt(9, compDoneWeekTeam);
ps.setInt(10, charId);
}
statement.execute();
ps.execute();
}
}
}
@@ -790,20 +791,20 @@ public class Olympiad extends ListenersContainer
{
saveNobleData();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(OLYMPIAD_SAVE_DATA))
{
statement.setInt(1, _currentCycle);
statement.setInt(2, _period);
statement.setLong(3, _olympiadEnd);
statement.setLong(4, _validationEnd);
statement.setLong(5, _nextWeeklyChange);
statement.setInt(6, _currentCycle);
statement.setInt(7, _period);
statement.setLong(8, _olympiadEnd);
statement.setLong(9, _validationEnd);
statement.setLong(10, _nextWeeklyChange);
statement.execute();
ps.setInt(1, _currentCycle);
ps.setInt(2, _period);
ps.setLong(3, _olympiadEnd);
ps.setLong(4, _validationEnd);
ps.setLong(5, _nextWeeklyChange);
ps.setInt(6, _currentCycle);
ps.setInt(7, _period);
ps.setLong(8, _olympiadEnd);
ps.setLong(9, _validationEnd);
ps.setLong(10, _nextWeeklyChange);
ps.execute();
}
catch (SQLException e)
{
@@ -831,12 +832,12 @@ public class Olympiad extends ListenersContainer
protected void updateMonthlyData()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
PreparedStatement ps2 = con.prepareStatement(OLYMPIAD_MONTH_CREATE))
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s1 = con.createStatement();
Statement s2 = con.createStatement())
{
ps1.execute();
ps2.execute();
s1.executeUpdate(OLYMPIAD_MONTH_CLEAR);
s2.executeUpdate(OLYMPIAD_MONTH_CREATE);
}
catch (SQLException e)
{
@@ -878,16 +879,16 @@ public class Olympiad extends ListenersContainer
_logResults.log(record);
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(OLYMPIAD_GET_HEROS))
{
StatsSet hero;
List<StatsSet> soulHounds = new ArrayList<>();
for (int element : HERO_IDS)
{
statement.setInt(1, element);
ps.setInt(1, element);
try (ResultSet rset = statement.executeQuery())
try (ResultSet rset = ps.executeQuery())
{
if (rset.next())
{
@@ -1011,15 +1012,15 @@ public class Olympiad extends ListenersContainer
{
final List<String> names = new ArrayList<>();
String query = Config.ALT_OLY_SHOW_MONTHLY_WINNERS ? ((classId == 132) ? GET_EACH_CLASS_LEADER_SOULHOUND : GET_EACH_CLASS_LEADER) : ((classId == 132) ? GET_EACH_CLASS_LEADER_CURRENT_SOULHOUND : GET_EACH_CLASS_LEADER_CURRENT);
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(query))
{
ps.setInt(1, classId);
try (ResultSet rset = ps.executeQuery())
try (ResultSet rs = ps.executeQuery())
{
while (rset.next())
while (rs.next())
{
names.add(rset.getString(CHAR_NAME));
names.add(rs.getString(CHAR_NAME));
}
}
}
@@ -1089,7 +1090,7 @@ public class Olympiad extends ListenersContainer
public int getLastNobleOlympiadPoints(int objId)
{
int result = 0;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?"))
{
ps.setInt(1, objId);
@@ -1233,10 +1234,10 @@ public class Olympiad extends ListenersContainer
protected void deleteNobles()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL))
try (Connection con = ConnectionFactory.getInstance().getConnection();
Statement s = con.createStatement())
{
statement.execute();
s.executeUpdate(OLYMPIAD_DELETE_ALL);
}
catch (SQLException e)
{

View File

@@ -27,7 +27,7 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Character;
@@ -793,18 +793,18 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
protected static final void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());
statement.setInt(2, two.getObjectId());
statement.setInt(3, one.getBaseClass());
statement.setInt(4, two.getBaseClass());
statement.setInt(5, winner);
statement.setLong(6, startTime);
statement.setLong(7, fightTime);
statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
statement.execute();
ps.setInt(1, one.getObjectId());
ps.setInt(2, two.getObjectId());
ps.setInt(3, one.getBaseClass());
ps.setInt(4, two.getBaseClass());
ps.setInt(5, winner);
ps.setLong(6, startTime);
ps.setLong(7, fightTime);
ps.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
ps.execute();
}
catch (SQLException e)
{

View File

@@ -27,7 +27,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.handler.IPunishmentHandler;
import com.l2jserver.gameserver.handler.PunishmentHandler;
@@ -184,17 +184,17 @@ public class PunishmentTask implements Runnable
{
if (!_isStored)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
{
st.setString(1, _key);
st.setString(2, _affect.name());
st.setString(3, _type.name());
st.setLong(4, _expirationTime);
st.setString(5, _reason);
st.setString(6, _punishedBy);
st.execute();
try (ResultSet rset = st.getGeneratedKeys())
ps.setString(1, _key);
ps.setString(2, _affect.name());
ps.setString(3, _type.name());
ps.setLong(4, _expirationTime);
ps.setString(5, _reason);
ps.setString(6, _punishedBy);
ps.execute();
try (ResultSet rset = ps.getGeneratedKeys())
{
if (rset.next())
{
@@ -223,12 +223,12 @@ public class PunishmentTask implements Runnable
{
if (_isStored)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
{
st.setLong(1, System.currentTimeMillis());
st.setLong(2, _id);
st.execute();
ps.setLong(1, System.currentTimeMillis());
ps.setLong(2, _id);
ps.execute();
}
catch (SQLException e)
{

View File

@@ -38,7 +38,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.enums.CategoryType;
import com.l2jserver.gameserver.enums.Race;
@@ -1492,7 +1492,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public static final void playerEnter(L2PcInstance player)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ?");
PreparedStatement invalidQuestDataVar = con.prepareStatement("DELETE FROM character_quests WHERE charId = ? AND name = ? AND var = ?");
PreparedStatement ps1 = con.prepareStatement("SELECT name, value FROM character_quests WHERE charId = ? AND var = ?"))
@@ -1581,13 +1581,13 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public final void saveGlobalQuestVar(String var, String value)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("REPLACE INTO quest_global_data (quest_name,var,value) VALUES (?,?,?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO quest_global_data (quest_name,var,value) VALUES (?,?,?)"))
{
statement.setString(1, getName());
statement.setString(2, var);
statement.setString(3, value);
statement.executeUpdate();
ps.setString(1, getName());
ps.setString(2, var);
ps.setString(3, value);
ps.executeUpdate();
}
catch (Exception e)
{
@@ -1607,12 +1607,12 @@ public class Quest extends AbstractScript implements IIdentifiable
public final String loadGlobalQuestVar(String var)
{
String result = "";
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT value FROM quest_global_data WHERE quest_name = ? AND var = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT value FROM quest_global_data WHERE quest_name = ? AND var = ?"))
{
statement.setString(1, getName());
statement.setString(2, var);
try (ResultSet rs = statement.executeQuery())
ps.setString(1, getName());
ps.setString(2, var);
try (ResultSet rs = ps.executeQuery())
{
if (rs.first())
{
@@ -1633,12 +1633,12 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public final void deleteGlobalQuestVar(String var)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ? AND var = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ? AND var = ?"))
{
statement.setString(1, getName());
statement.setString(2, var);
statement.executeUpdate();
ps.setString(1, getName());
ps.setString(2, var);
ps.executeUpdate();
}
catch (Exception e)
{
@@ -1651,11 +1651,11 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public final void deleteAllGlobalQuestVars()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM quest_global_data WHERE quest_name = ?"))
{
statement.setString(1, getName());
statement.executeUpdate();
ps.setString(1, getName());
ps.executeUpdate();
}
catch (Exception e)
{
@@ -1671,15 +1671,15 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public static void createQuestVarInDb(QuestState qs, String var, String value)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?"))
{
statement.setInt(1, qs.getPlayer().getObjectId());
statement.setString(2, qs.getQuestName());
statement.setString(3, var);
statement.setString(4, value);
statement.setString(5, value);
statement.executeUpdate();
ps.setInt(1, qs.getPlayer().getObjectId());
ps.setString(2, qs.getQuestName());
ps.setString(3, var);
ps.setString(4, value);
ps.setString(5, value);
ps.executeUpdate();
}
catch (Exception e)
{
@@ -1695,14 +1695,14 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public static void updateQuestVarInDb(QuestState qs, String var, String value)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?"))
{
statement.setString(1, value);
statement.setInt(2, qs.getPlayer().getObjectId());
statement.setString(3, qs.getQuestName());
statement.setString(4, var);
statement.executeUpdate();
ps.setString(1, value);
ps.setInt(2, qs.getPlayer().getObjectId());
ps.setString(3, qs.getQuestName());
ps.setString(4, var);
ps.executeUpdate();
}
catch (Exception e)
{
@@ -1717,13 +1717,13 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public static void deleteQuestVarInDb(QuestState qs, String var)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?"))
{
statement.setInt(1, qs.getPlayer().getObjectId());
statement.setString(2, qs.getQuestName());
statement.setString(3, var);
statement.executeUpdate();
ps.setInt(1, qs.getPlayer().getObjectId());
ps.setString(2, qs.getQuestName());
ps.setString(3, var);
ps.executeUpdate();
}
catch (Exception e)
{
@@ -1738,7 +1738,7 @@ public class Quest extends AbstractScript implements IIdentifiable
*/
public static void deleteQuestInDb(QuestState qs, boolean repeatable)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(repeatable ? QUEST_DELETE_FROM_CHAR_QUERY : QUEST_DELETE_FROM_CHAR_QUERY_NON_REPEATABLE_QUERY))
{
ps.setInt(1, qs.getPlayer().getObjectId());

View File

@@ -28,7 +28,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.enums.QuestSound;
import com.l2jserver.gameserver.enums.QuestType;
import com.l2jserver.gameserver.instancemanager.PcCafePointsManager;
@@ -401,13 +401,13 @@ public final class QuestState
// TODO: these methods should not be here, they could be used by other classes to save some variables, but they can't because they require to create a QuestState first.
public final void saveGlobalQuestVar(String var, String value)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_quest_global_data (charId, var, value) VALUES (?, ?, ?)"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_quest_global_data (charId, var, value) VALUES (?, ?, ?)"))
{
statement.setInt(1, _player.getObjectId());
statement.setString(2, var);
statement.setString(3, value);
statement.executeUpdate();
ps.setInt(1, _player.getObjectId());
ps.setString(2, var);
ps.setString(3, value);
ps.executeUpdate();
}
catch (Exception e)
{
@@ -428,7 +428,7 @@ public final class QuestState
public final String getGlobalQuestVar(String var)
{
String result = "";
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("SELECT value FROM character_quest_global_data WHERE charId = ? AND var = ?"))
{
ps.setInt(1, _player.getObjectId());
@@ -454,12 +454,12 @@ public final class QuestState
*/
public final void deleteGlobalQuestVar(String var)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("DELETE FROM character_quest_global_data WHERE charId = ? AND var = ?"))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_quest_global_data WHERE charId = ? AND var = ?"))
{
statement.setInt(1, _player.getObjectId());
statement.setString(2, var);
statement.executeUpdate();
ps.setInt(1, _player.getObjectId());
ps.setString(2, var);
ps.executeUpdate();
}
catch (Exception e)
{

View File

@@ -26,7 +26,7 @@ import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
/**
* @author UnAfraid
@@ -52,7 +52,7 @@ public class AccountVariables extends AbstractVariables
public boolean restoreMe()
{
// Restore previous variables.
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(SELECT_QUERY))
{
st.setString(1, _accountName);
@@ -85,7 +85,7 @@ public class AccountVariables extends AbstractVariables
return false;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
@@ -122,7 +122,7 @@ public class AccountVariables extends AbstractVariables
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

View File

@@ -26,7 +26,7 @@ import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
/**
* @author UnAfraid
@@ -57,7 +57,7 @@ public class ItemVariables extends AbstractVariables
public static boolean hasVariables(int objectId)
{
// Restore previous variables.
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(SELECT_COUNT))
{
st.setInt(1, objectId);
@@ -81,7 +81,7 @@ public class ItemVariables extends AbstractVariables
public boolean restoreMe()
{
// Restore previous variables.
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(SELECT_QUERY))
{
st.setInt(1, _objectId);
@@ -114,7 +114,7 @@ public class ItemVariables extends AbstractVariables
return false;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
@@ -151,7 +151,7 @@ public class ItemVariables extends AbstractVariables
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))

View File

@@ -26,7 +26,7 @@ import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -54,11 +54,11 @@ public class PlayerVariables extends AbstractVariables
public boolean restoreMe()
{
// Restore previous variables.
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(SELECT_QUERY))
try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(SELECT_QUERY))
{
st.setInt(1, _objectId);
try (ResultSet rset = st.executeQuery())
ps.setInt(1, _objectId);
try (ResultSet rset = ps.executeQuery())
{
while (rset.next())
{
@@ -87,7 +87,7 @@ public class PlayerVariables extends AbstractVariables
return false;
}
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
@@ -124,7 +124,7 @@ public class PlayerVariables extends AbstractVariables
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
try (Connection con = ConnectionFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))