Dropped c3p0 in favor of HikariCP.
This commit is contained in:
parent
6fd681adcf
commit
eb3742d44f
@ -5,11 +5,12 @@
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/c3p0-0.9.5.2.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/HikariCP-3.2.0.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/JavaC.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mchange-commons-java-0.2.12.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.46.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.28.Final.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/slf4j-api-1.7.25.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/slf4j-simple-1.7.25.jar"/>
|
||||
<classpathentry including="**/*.java" kind="src" path="dist/game/data/scripts"/>
|
||||
<classpathentry kind="src" path="java"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
@ -76,7 +76,7 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
|
||||
statement.setInt(1, lvl);
|
||||
|
@ -631,7 +631,7 @@ public class AdminEditChar implements IAdminCommandHandler
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
final Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
final Connection con = DatabaseFactory.getConnection();
|
||||
final PreparedStatement ps = con.prepareStatement("UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1");
|
||||
|
||||
ps.setString(1, playerName);
|
||||
|
@ -62,7 +62,7 @@ public class AdminRepairChar implements IAdminCommandHandler
|
||||
}
|
||||
|
||||
final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(cmd);
|
||||
statement.setString(1, parts[1]);
|
||||
@ -87,13 +87,13 @@ public class AdminRepairChar implements IAdminCommandHandler
|
||||
return;
|
||||
}
|
||||
|
||||
// connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
// connection = L2DatabaseFactory.getConnection();
|
||||
statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
// connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
// connection = L2DatabaseFactory.getConnection();
|
||||
statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
|
@ -173,7 +173,7 @@ public class AdminShowQuests implements IAdminCommandHandler
|
||||
|
||||
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
ResultSet rs;
|
||||
PreparedStatement req;
|
||||
|
@ -489,7 +489,7 @@ public class AdminTeleport implements IAdminCommandHandler
|
||||
final int x = activeChar.getX();
|
||||
final int y = activeChar.getY();
|
||||
final int z = activeChar.getZ();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
|
||||
statement.setInt(1, x);
|
||||
|
@ -61,7 +61,7 @@ public class FavoriteBoard implements IParseBoardHandler
|
||||
// Load Favorite links
|
||||
final String list = HtmCache.getInstance().getHtm(activeChar, "data/html/CommunityBoard/favorite_list.html");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
@ -98,7 +98,7 @@ public class FavoriteBoard implements IParseBoardHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
@ -123,7 +123,7 @@ public class FavoriteBoard implements IParseBoardHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
|
@ -300,7 +300,7 @@ public final class HomeBoard implements IParseBoardHandler
|
||||
private static int getFavoriteCount(L2PcInstance player)
|
||||
{
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
|
||||
{
|
||||
ps.setInt(1, player.getObjectId());
|
||||
|
@ -62,7 +62,7 @@ public class ClanWarsList implements IUserCommandHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
String query;
|
||||
// Attack List
|
||||
|
2
L2J_Mobius_1.0_Ertheia/dist/game/java.cfg
vendored
2
L2J_Mobius_1.0_Ertheia/dist/game/java.cfg
vendored
@ -1 +1 @@
|
||||
-server -Dfile.encoding=UTF-8 -Djava.util.logging.manager=com.l2jmobius.log.L2LogManager -XX:+AggressiveOpts -Xnoclassgc -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -Xmx4g -Xms2g -Xmn1g
|
||||
-server -Dfile.encoding=UTF-8 -Djava.util.logging.manager=com.l2jmobius.log.L2LogManager -Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=error -XX:+AggressiveOpts -Xnoclassgc -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -Xmx4g -Xms2g -Xmn1g
|
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.2.0.jar
vendored
Normal file
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/HikariCP-3.2.0.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/c3p0-0.9.5.2.jar
vendored
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/c3p0-0.9.5.2.jar
vendored
Binary file not shown.
Binary file not shown.
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.25.jar
vendored
Normal file
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-api-1.7.25.jar
vendored
Normal file
Binary file not shown.
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.25.jar
vendored
Normal file
BIN
L2J_Mobius_1.0_Ertheia/dist/libs/slf4j-simple-1.7.25.jar
vendored
Normal file
Binary file not shown.
2
L2J_Mobius_1.0_Ertheia/dist/login/java.cfg
vendored
2
L2J_Mobius_1.0_Ertheia/dist/login/java.cfg
vendored
@ -1 +1 @@
|
||||
-server -Xms128m -Xmx256m
|
||||
-server -Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=error -Xms128m -Xmx256m
|
@ -16,122 +16,68 @@
|
||||
*/
|
||||
package com.l2jmobius.commons.database;
|
||||
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
/**
|
||||
* Database Factory implementation.
|
||||
* @author Zoey76, Mobius
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DatabaseFactory
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(DatabaseFactory.class.getName());
|
||||
|
||||
private final ComboPooledDataSource _dataSource;
|
||||
private static final HikariDataSource _hds = new HikariDataSource();
|
||||
|
||||
public DatabaseFactory()
|
||||
public static void init()
|
||||
{
|
||||
if (Config.DATABASE_MAX_CONNECTIONS < 2)
|
||||
{
|
||||
Config.DATABASE_MAX_CONNECTIONS = 2;
|
||||
LOGGER.warning("A minimum of 2 connections are required.");
|
||||
}
|
||||
|
||||
_dataSource = new ComboPooledDataSource();
|
||||
_dataSource.setAutoCommitOnClose(true);
|
||||
|
||||
_dataSource.setInitialPoolSize(10);
|
||||
_dataSource.setMinPoolSize(10);
|
||||
_dataSource.setMaxPoolSize(Math.max(10, Config.DATABASE_MAX_CONNECTIONS));
|
||||
|
||||
_dataSource.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
|
||||
_dataSource.setAcquireRetryDelay(500); // 500 milliseconds wait before try to acquire connection again
|
||||
_dataSource.setCheckoutTimeout(0); // 0 = wait indefinitely for new connection if pool is exhausted
|
||||
_dataSource.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time cause there is
|
||||
// a "long" delay on acquire connection so taking more than one connection at once will make connection pooling more effective.
|
||||
|
||||
// this "connection_test_table" is automatically created if not already there
|
||||
_dataSource.setAutomaticTestTable("connection_test_table");
|
||||
_dataSource.setTestConnectionOnCheckin(false);
|
||||
|
||||
// testing OnCheckin used with IdleConnectionTestPeriod is faster than testing on checkout
|
||||
|
||||
_dataSource.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
|
||||
_dataSource.setMaxIdleTime(Config.DATABASE_MAX_IDLE_TIME); // 0 = idle connections never expire
|
||||
// *THANKS* to connection testing configured above but I prefer to disconnect all connections not used for more than 1 hour
|
||||
|
||||
// enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
|
||||
_dataSource.setMaxStatementsPerConnection(100);
|
||||
|
||||
_dataSource.setBreakAfterAcquireFailure(false); // never fail if any way possible setting this to true will make c3p0 "crash"
|
||||
// and refuse to work till restart thus making acquire errors "FATAL" ... we don't want that it should be possible to recover
|
||||
_hds.setDriverClassName(Config.DATABASE_DRIVER);
|
||||
_hds.setJdbcUrl(Config.DATABASE_URL);
|
||||
_hds.setUsername(Config.DATABASE_LOGIN);
|
||||
_hds.setPassword(Config.DATABASE_PASSWORD);
|
||||
_hds.setMaximumPoolSize(Config.DATABASE_MAX_CONNECTIONS);
|
||||
_hds.setIdleTimeout(Config.DATABASE_MAX_IDLE_TIME);
|
||||
|
||||
// Test if connection is valid.
|
||||
try
|
||||
{
|
||||
_dataSource.setDriverClass(Config.DATABASE_DRIVER);
|
||||
}
|
||||
catch (PropertyVetoException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
_dataSource.setJdbcUrl(Config.DATABASE_URL);
|
||||
_dataSource.setUser(Config.DATABASE_LOGIN);
|
||||
_dataSource.setPassword(Config.DATABASE_PASSWORD);
|
||||
|
||||
/* Test the connection */
|
||||
try
|
||||
{
|
||||
_dataSource.getConnection().close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
_hds.getConnection().close();
|
||||
LOGGER.info("Database: Initialized.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getConnection()
|
||||
public static Connection getConnection()
|
||||
{
|
||||
Connection con = null;
|
||||
while (con == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
con = _dataSource.getConnection();
|
||||
con = _hds.getConnection();
|
||||
}
|
||||
catch (SQLException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Unable to get a connection: " + e.getMessage());
|
||||
LOGGER.severe("DatabaseFactory: Cound not get a connection. " + e);
|
||||
}
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
public void close()
|
||||
public static void close()
|
||||
{
|
||||
try
|
||||
{
|
||||
_dataSource.close();
|
||||
_hds.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.info(e.getMessage());
|
||||
LOGGER.severe("DatabaseFactory: There was a problem closing the data source. " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public static DatabaseFactory getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final DatabaseFactory INSTANCE = new DatabaseFactory();
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class GameServer
|
||||
// Initialize config
|
||||
Config.load();
|
||||
printSection("Database");
|
||||
DatabaseFactory.getInstance();
|
||||
DatabaseFactory.init();
|
||||
|
||||
printSection("ThreadPool");
|
||||
ThreadPool.init();
|
||||
|
@ -584,7 +584,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
int chars = 0;
|
||||
final List<Long> charToDel = new ArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT deletetime FROM characters WHERE account_name=?"))
|
||||
{
|
||||
ps.setString(1, account);
|
||||
|
@ -204,7 +204,7 @@ public class Shutdown extends Thread
|
||||
// commit data, last chance
|
||||
try
|
||||
{
|
||||
DatabaseFactory.getInstance().close();
|
||||
DatabaseFactory.close();
|
||||
LOGGER.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
|
@ -93,7 +93,7 @@ public class Forum
|
||||
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM forums WHERE forum_id=?"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
@ -114,7 +114,7 @@ public class Forum
|
||||
LOGGER.log(Level.WARNING, "Data error on Forum " + _forumId + " : " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM topic WHERE topic_forum_id=? ORDER BY topic_id DESC"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
@ -139,7 +139,7 @@ public class Forum
|
||||
|
||||
private void getChildren()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT forum_id FROM forums WHERE forum_parent=?"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
@ -217,7 +217,7 @@ public class Forum
|
||||
|
||||
public void insertIntoDb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO forums (forum_id,forum_name,forum_parent,forum_post,forum_type,forum_perm,forum_owner_id) VALUES (?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _forumId);
|
||||
|
@ -72,7 +72,7 @@ public class Post
|
||||
|
||||
private void insertindb(CPost cp)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, cp.postId);
|
||||
@ -112,7 +112,7 @@ public class Post
|
||||
public void deleteme(Topic t)
|
||||
{
|
||||
PostBBSManager.getInstance().delPostByTopic(t);
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM posts WHERE post_forum_id=? AND post_topic_id=?"))
|
||||
{
|
||||
ps.setInt(1, t.getForumID());
|
||||
@ -130,7 +130,7 @@ public class Post
|
||||
*/
|
||||
private void load(Topic t)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM posts WHERE post_forum_id=? AND post_topic_id=? ORDER BY post_id ASC"))
|
||||
{
|
||||
ps.setInt(1, t.getForumID());
|
||||
@ -162,7 +162,7 @@ public class Post
|
||||
*/
|
||||
public void updatetxt(int i)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE posts SET post_txt=? WHERE post_id=? AND post_topic_id=? AND post_forum_id=?"))
|
||||
{
|
||||
final CPost cp = getCPost(i);
|
||||
|
@ -71,7 +71,7 @@ public class Topic
|
||||
|
||||
private void insertindb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO topic (topic_id,topic_forum_id,topic_name,topic_date,topic_ownername,topic_ownerid,topic_type,topic_reply) values (?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _id);
|
||||
@ -129,7 +129,7 @@ public class Topic
|
||||
{
|
||||
TopicBBSManager.getInstance().delTopic(this);
|
||||
f.rmTopicByID(_id);
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?"))
|
||||
{
|
||||
ps.setInt(1, _id);
|
||||
|
@ -40,7 +40,7 @@ public class ForumsBBSManager extends BaseBBSManager
|
||||
protected ForumsBBSManager()
|
||||
{
|
||||
_table = new CopyOnWriteArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT forum_id FROM forums WHERE forum_type = 0"))
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public final class AnnouncementsTable
|
||||
private void load()
|
||||
{
|
||||
_announcements.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement st = con.createStatement();
|
||||
ResultSet rset = st.executeQuery("SELECT * FROM announcements"))
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ public class CharNameTable
|
||||
int id = -1;
|
||||
int accessLevel = 0;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT charId,accesslevel FROM characters WHERE char_name=?"))
|
||||
{
|
||||
ps.setString(1, name);
|
||||
@ -145,7 +145,7 @@ public class CharNameTable
|
||||
return null;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT char_name,accesslevel FROM characters WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, id);
|
||||
@ -176,7 +176,7 @@ public class CharNameTable
|
||||
public synchronized boolean doesCharNameExist(String name)
|
||||
{
|
||||
boolean result = false;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) as count FROM characters WHERE char_name=?"))
|
||||
{
|
||||
ps.setString(1, name);
|
||||
@ -197,7 +197,7 @@ public class CharNameTable
|
||||
|
||||
public int getAccountCharacterCount(String account)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT COUNT(char_name) as count FROM characters WHERE account_name=?"))
|
||||
{
|
||||
ps.setString(1, account);
|
||||
@ -218,7 +218,7 @@ public class CharNameTable
|
||||
|
||||
public int getLevelById(int objectId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT level FROM characters WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, objectId);
|
||||
@ -239,7 +239,7 @@ public class CharNameTable
|
||||
|
||||
public int getClassIdById(int objectId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT classid FROM characters WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, objectId);
|
||||
@ -260,7 +260,7 @@ public class CharNameTable
|
||||
|
||||
public int getClanIdById(int objectId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT clanId FROM characters WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, objectId);
|
||||
@ -281,7 +281,7 @@ public class CharNameTable
|
||||
|
||||
private void loadAll()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT charId, char_name, accesslevel FROM characters"))
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ public class CharSummonTable
|
||||
{
|
||||
if (Config.RESTORE_SERVITOR_ON_RECONNECT)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery(INIT_SUMMONS))
|
||||
{
|
||||
@ -87,7 +87,7 @@ public class CharSummonTable
|
||||
|
||||
if (Config.RESTORE_PET_ON_RECONNECT)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery(INIT_PET))
|
||||
{
|
||||
@ -111,7 +111,7 @@ public class CharSummonTable
|
||||
return !v.isEmpty() ? v : null;
|
||||
});
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(REMOVE_SUMMON))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
@ -181,7 +181,7 @@ public class CharSummonTable
|
||||
|
||||
public void restoreServitor(L2PcInstance activeChar)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(LOAD_SUMMON))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
@ -229,7 +229,7 @@ public class CharSummonTable
|
||||
|
||||
_servitors.computeIfAbsent(summon.getOwner().getObjectId(), k -> ConcurrentHashMap.newKeySet()).add(summon.getObjectId());
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SAVE_SUMMON))
|
||||
{
|
||||
ps.setInt(1, summon.getOwner().getObjectId());
|
||||
|
@ -79,7 +79,7 @@ public class ClanTable
|
||||
L2Clan clan;
|
||||
// Count the clans
|
||||
int clanCount = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT clan_id FROM clan_data"))
|
||||
{
|
||||
@ -258,7 +258,7 @@ public class ClanTable
|
||||
_clans.remove(clanId);
|
||||
IdFactory.getInstance().releaseId(clanId);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM clan_data WHERE clan_id=?"))
|
||||
{
|
||||
@ -357,7 +357,7 @@ public class ClanTable
|
||||
|
||||
public void storeclanswars(ClanWar war)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO clan_wars (clan1, clan2, clan1Kill, clan2Kill, winnerClan, startTime, endTime, state) VALUES(?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, war.getAttackerClanId());
|
||||
@ -388,7 +388,7 @@ public class ClanTable
|
||||
clan1.broadcastClanStatus();
|
||||
clan2.broadcastClanStatus();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM clan_wars WHERE clan1=? AND clan2=?"))
|
||||
{
|
||||
ps.setInt(1, clanId1);
|
||||
@ -403,7 +403,7 @@ public class ClanTable
|
||||
|
||||
private void restorewars()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet rset = statement.executeQuery("SELECT clan1, clan2, clan1Kill, clan2Kill, winnerClan, startTime, endTime, state FROM clan_wars"))
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ public final class CrestTable
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement statement = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
|
||||
ResultSet rs = statement.executeQuery("SELECT `crest_id`, `data`, `type` FROM `crests` ORDER BY `crest_id` DESC"))
|
||||
{
|
||||
@ -154,7 +154,7 @@ public final class CrestTable
|
||||
*/
|
||||
public L2Crest createCrest(byte[] data, CrestType crestType)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO `crests`(`crest_id`, `data`, `type`) VALUES(?, ?, ?)"))
|
||||
{
|
||||
final L2Crest crest = new L2Crest(_nextId.getAndIncrement(), data, crestType);
|
||||
@ -187,7 +187,7 @@ public final class CrestTable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM `crests` WHERE `crest_id` = ?"))
|
||||
{
|
||||
statement.setInt(1, crestId);
|
||||
|
@ -56,7 +56,7 @@ public class OfflineTradersTable
|
||||
|
||||
public void storeOffliners()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE);
|
||||
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS);
|
||||
PreparedStatement stm3 = con.prepareStatement(SAVE_OFFLINE_STATUS);
|
||||
@ -173,7 +173,7 @@ public class OfflineTradersTable
|
||||
{
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loading offline traders...");
|
||||
int nTraders = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement stm = con.createStatement();
|
||||
ResultSet rs = stm.executeQuery(LOAD_OFFLINE_STATUS))
|
||||
{
|
||||
@ -329,7 +329,7 @@ public class OfflineTradersTable
|
||||
|
||||
public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER);
|
||||
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER);
|
||||
PreparedStatement stm3 = con.prepareStatement(SAVE_ITEMS);
|
||||
@ -453,7 +453,7 @@ public class OfflineTradersTable
|
||||
{
|
||||
PlayerCountManager.getInstance().decOfflineTradeCount();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER);
|
||||
PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER))
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ public class PetNameTable
|
||||
public boolean doesPetNameExist(String name, int petNpcId)
|
||||
{
|
||||
boolean result = true;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT name FROM pets p, items i WHERE p.item_obj_id = i.object_id AND name=? AND i.item_id IN (?)"))
|
||||
{
|
||||
ps.setString(1, name);
|
||||
|
@ -66,7 +66,7 @@ public final class BuyListData implements IGameXmlReader
|
||||
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _buyLists.size() + " BuyLists.");
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet rs = statement.executeQuery("SELECT * FROM `buylists`"))
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ public final class BotReportTable
|
||||
*/
|
||||
private void loadReportedCharData()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement st = con.createStatement();
|
||||
ResultSet rset = st.executeQuery(SQL_LOAD_REPORTED_CHAR_DATA))
|
||||
{
|
||||
@ -181,7 +181,7 @@ public final class BotReportTable
|
||||
*/
|
||||
public void saveReportedCharData()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement st = con.createStatement();
|
||||
PreparedStatement ps = con.prepareStatement(SQL_INSERT_REPORTED_CHAR_DATA))
|
||||
{
|
||||
|
@ -386,7 +386,7 @@ public class ItemTable
|
||||
// if it's a pet control item, delete the pet as well
|
||||
if (item.getItem().isPetItem())
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?"))
|
||||
{
|
||||
// Delete the pet in db
|
||||
|
@ -128,7 +128,7 @@ public abstract class IdFactory
|
||||
*/
|
||||
private void setAllCharacterOffline()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement())
|
||||
{
|
||||
s.executeUpdate("UPDATE characters SET online = 0");
|
||||
@ -145,7 +145,7 @@ public abstract class IdFactory
|
||||
*/
|
||||
private void cleanUpDB()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement stmt = con.createStatement())
|
||||
{
|
||||
final long cleanupStart = System.currentTimeMillis();
|
||||
@ -253,7 +253,7 @@ public abstract class IdFactory
|
||||
|
||||
private void cleanUpTimeStamps()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
int cleanCount = 0;
|
||||
for (String line : TIMESTAMPS_CLEAN)
|
||||
@ -279,7 +279,7 @@ public abstract class IdFactory
|
||||
protected final Integer[] extractUsedObjectIDTable() throws Exception
|
||||
{
|
||||
final List<Integer> temp = new ArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement())
|
||||
{
|
||||
String extractUsedObjectIdsQuery = "";
|
||||
|
@ -42,7 +42,7 @@ public class StackIDFactory extends IdFactory
|
||||
_curOID = FIRST_OID;
|
||||
_tempOID = FIRST_OID;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// con.createStatement().execute("drop table if exists tmp_obj_id");
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class AirShipManager
|
||||
|
||||
_airShipsInfo.put(ownerId, info);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ADD_DB))
|
||||
{
|
||||
ps.setInt(1, ownerId);
|
||||
@ -265,7 +265,7 @@ public class AirShipManager
|
||||
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery(LOAD_DB))
|
||||
{
|
||||
@ -296,7 +296,7 @@ public class AirShipManager
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(UPDATE_DB))
|
||||
{
|
||||
ps.setInt(1, info.getInt("fuel"));
|
||||
|
@ -198,7 +198,7 @@ public final class CastleManager implements InstanceListManager
|
||||
}
|
||||
}
|
||||
// else offline-player circlet removal
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE owner_id = ? and item_id = ?"))
|
||||
{
|
||||
ps.setInt(1, member.getObjectId());
|
||||
@ -215,7 +215,7 @@ public final class CastleManager implements InstanceListManager
|
||||
@Override
|
||||
public void loadInstances()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT id FROM castle ORDER BY id"))
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
|
||||
private void loadDb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stProduction = con.prepareStatement("SELECT * FROM castle_manor_production WHERE castle_id=?");
|
||||
PreparedStatement stProcure = con.prepareStatement("SELECT * FROM castle_manor_procure WHERE castle_id=?"))
|
||||
{
|
||||
@ -436,7 +436,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
_productionNext.put(castleId, list);
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ? AND next_period = 1");
|
||||
PreparedStatement ips = con.prepareStatement(INSERT_PRODUCT))
|
||||
{
|
||||
@ -472,7 +472,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
_procureNext.put(castleId, list);
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement dps = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ? AND next_period = 1");
|
||||
PreparedStatement ips = con.prepareStatement(INSERT_CROP))
|
||||
{
|
||||
@ -506,7 +506,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
|
||||
public final void updateCurrentProduction(int castleId, Collection<SeedProduction> items)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_production SET amount = ? WHERE castle_id = ? AND seed_id = ? AND next_period = 0"))
|
||||
{
|
||||
for (SeedProduction sp : items)
|
||||
@ -526,7 +526,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
|
||||
public final void updateCurrentProcure(int castleId, Collection<CropProcure> items)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle_manor_procure SET amount = ? WHERE castle_id = ? AND crop_id = ? AND next_period = 0"))
|
||||
{
|
||||
for (CropProcure sp : items)
|
||||
@ -599,7 +599,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
@Override
|
||||
public final boolean storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production");
|
||||
PreparedStatement is = con.prepareStatement(INSERT_PRODUCT);
|
||||
PreparedStatement dp = con.prepareStatement("DELETE FROM castle_manor_procure");
|
||||
@ -697,7 +697,7 @@ public final class CastleManorManager implements IGameXmlReader, IStorable
|
||||
|
||||
if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ds = con.prepareStatement("DELETE FROM castle_manor_production WHERE castle_id = ?");
|
||||
PreparedStatement dc = con.prepareStatement("DELETE FROM castle_manor_procure WHERE castle_id = ?"))
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MARKS, 0);
|
||||
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.COC_TOP_MEMBER, 0);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
|
||||
{
|
||||
ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_MARKS);
|
||||
@ -102,7 +102,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
|
||||
LOGGER.severe(getClass().getSimpleName() + ": Could not reset Ceremony Of Chaos victories: " + e);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
|
||||
{
|
||||
ps.setString(1, PlayerVariables.CEREMONY_OF_CHAOS_PROHIBITED_PENALTIES);
|
||||
|
@ -91,7 +91,7 @@ public class ClanEntryManager
|
||||
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT * FROM pledge_recruit"))
|
||||
{
|
||||
@ -106,7 +106,7 @@ public class ClanEntryManager
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Failed to load: ", e);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT a.char_id, a.karma, b.base_class, b.level, b.char_name FROM pledge_waiting_list as a LEFT JOIN characters as b ON a.char_id = b.charId"))
|
||||
{
|
||||
@ -122,7 +122,7 @@ public class ClanEntryManager
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Failed to load: ", e);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT a.charId, a.clanId, a.karma, a.message, b.base_class, b.level, b.char_name FROM pledge_applicant as a LEFT JOIN characters as b ON a.charId = b.charId"))
|
||||
{
|
||||
@ -168,7 +168,7 @@ public class ClanEntryManager
|
||||
{
|
||||
final Map<Integer, PledgeApplicantInfo> clanApplicantList = _applicantList.get(clanId);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_APPLICANT))
|
||||
{
|
||||
statement.setInt(1, playerId);
|
||||
@ -189,7 +189,7 @@ public class ClanEntryManager
|
||||
{
|
||||
_applicantList.computeIfAbsent(clanId, k -> new ConcurrentHashMap<>()).put(info.getPlayerId(), info);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(INSERT_APPLICANT))
|
||||
{
|
||||
statement.setInt(1, info.getPlayerId());
|
||||
@ -216,7 +216,7 @@ public class ClanEntryManager
|
||||
{
|
||||
if (!_playerLocked.containsKey(playerId))
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(INSERT_WAITING_LIST))
|
||||
{
|
||||
statement.setInt(1, info.getPlayerId());
|
||||
@ -237,7 +237,7 @@ public class ClanEntryManager
|
||||
{
|
||||
if (_waitingList.containsKey(playerId))
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_WAITING_LIST))
|
||||
{
|
||||
statement.setInt(1, playerId);
|
||||
@ -258,7 +258,7 @@ public class ClanEntryManager
|
||||
{
|
||||
if (!_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(INSERT_CLAN_RECRUIT))
|
||||
{
|
||||
statement.setInt(1, info.getClanId());
|
||||
@ -283,7 +283,7 @@ public class ClanEntryManager
|
||||
{
|
||||
if (_clanList.containsKey(clanId) && !_clanLocked.containsKey(clanId))
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_CLAN_RECRUIT))
|
||||
{
|
||||
statement.setInt(1, info.getKarma());
|
||||
@ -307,7 +307,7 @@ public class ClanEntryManager
|
||||
{
|
||||
if (_clanList.containsKey(clanId))
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_CLAN_RECRUIT))
|
||||
{
|
||||
statement.setInt(1, clanId);
|
||||
|
@ -79,7 +79,7 @@ public final class CommissionManager
|
||||
protected CommissionManager()
|
||||
{
|
||||
final Map<Integer, L2ItemInstance> itemInstances = new HashMap<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement(SELECT_ALL_ITEMS))
|
||||
{
|
||||
@ -245,7 +245,7 @@ public final class CommissionManager
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(INSERT_COMMISSION_ITEM, Statement.RETURN_GENERATED_KEYS))
|
||||
{
|
||||
final Instant startTime = Instant.now();
|
||||
@ -398,7 +398,7 @@ public final class CommissionManager
|
||||
*/
|
||||
private boolean deleteItemFromDB(long commissionId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_COMMISSION_ITEM))
|
||||
{
|
||||
ps.setLong(1, commissionId);
|
||||
|
@ -142,7 +142,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
|
||||
|
||||
private void restore()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT itemId, charId, playerReputation, playerPkKills, nbKills, endTime FROM cursed_weapons"))
|
||||
{
|
||||
@ -167,7 +167,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
|
||||
|
||||
private void controlPlayers()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?"))
|
||||
{
|
||||
// TODO: See comments below...
|
||||
@ -338,7 +338,7 @@ public final class CursedWeaponsManager implements IGameXmlReader
|
||||
|
||||
public static void removeFromDb(int itemId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?"))
|
||||
{
|
||||
ps.setInt(1, itemId);
|
||||
|
@ -85,7 +85,7 @@ public class DBSpawnManager
|
||||
_storedInfo.clear();
|
||||
_schedules.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM npc_respawns");
|
||||
ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
@ -275,7 +275,7 @@ public class DBSpawnManager
|
||||
|
||||
if (storeInDb)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO npc_respawns (id, x, y, z, heading, respawnTime, currentHp, currentMp) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"))
|
||||
{
|
||||
statement.setInt(1, spawn.getId());
|
||||
@ -331,7 +331,7 @@ public class DBSpawnManager
|
||||
|
||||
if (storeInDb)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO npc_respawns (id, x, y, z, heading, respawnTime, currentHp, currentMp) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"))
|
||||
{
|
||||
statement.setInt(1, spawn.getId());
|
||||
@ -380,7 +380,7 @@ public class DBSpawnManager
|
||||
|
||||
if (updateDb)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM npc_respawns WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, npcId);
|
||||
@ -401,7 +401,7 @@ public class DBSpawnManager
|
||||
*/
|
||||
private void updateDb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE npc_respawns SET respawnTime = ?, currentHP = ?, currentMP = ? WHERE id = ?"))
|
||||
{
|
||||
for (Integer npcId : _storedInfo.keySet())
|
||||
|
@ -117,7 +117,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement st = con.prepareStatement("UPDATE character_subclasses SET vitality_points = ?"))
|
||||
{
|
||||
@ -147,7 +147,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
|
||||
private void resetExtendDrop()
|
||||
{
|
||||
// Update data for offline players.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var = ?"))
|
||||
{
|
||||
ps.setString(1, PlayerVariables.EXTEND_DROP);
|
||||
@ -170,7 +170,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
|
||||
|
||||
private void resetDailySkills()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final List<SkillHolder> dailySkills = getVariables().getList("reset_skills", SkillHolder.class, Collections.emptyList());
|
||||
for (SkillHolder skill : dailySkills)
|
||||
@ -197,7 +197,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
|
||||
}
|
||||
|
||||
// Update data for offline players.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE character_variables SET val = ? WHERE var = ?"))
|
||||
{
|
||||
ps.setInt(1, 0);
|
||||
@ -222,7 +222,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
|
||||
|
||||
private void resetRecommends()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE character_reco_bonus SET rec_left = ?, rec_have = 0 WHERE rec_have <= 20"))
|
||||
{
|
||||
@ -255,7 +255,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
|
||||
if (Config.TRAINING_CAMP_ENABLE)
|
||||
{
|
||||
// Update data for offline players.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM account_gsdata WHERE var = ?"))
|
||||
{
|
||||
ps.setString(1, "TRAINING_CAMP_DURATION");
|
||||
|
@ -46,7 +46,7 @@ public class FactionManager
|
||||
private void loadAll()
|
||||
{
|
||||
_playerFactions.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT charId, faction FROM characters"))
|
||||
{
|
||||
@ -75,7 +75,7 @@ public class FactionManager
|
||||
return factionId;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT faction FROM characters WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, id);
|
||||
|
@ -121,7 +121,7 @@ public final class FortManager implements InstanceListManager
|
||||
@Override
|
||||
public void loadInstances()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT id FROM fort ORDER BY id"))
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ public final class FortSiegeManager
|
||||
}
|
||||
|
||||
boolean register = false;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans where clan_id=? and fort_id=?"))
|
||||
{
|
||||
ps.setInt(1, clan.getId());
|
||||
|
@ -56,7 +56,7 @@ public final class GlobalVariablesManager extends AbstractVariables
|
||||
public boolean restoreMe()
|
||||
{
|
||||
// Restore previous variables.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement st = con.createStatement();
|
||||
ResultSet rset = st.executeQuery(SELECT_QUERY))
|
||||
{
|
||||
@ -87,7 +87,7 @@ public final class GlobalVariablesManager extends AbstractVariables
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement del = con.createStatement();
|
||||
PreparedStatement st = con.prepareStatement(INSERT_QUERY))
|
||||
{
|
||||
@ -119,7 +119,7 @@ public final class GlobalVariablesManager extends AbstractVariables
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement del = con.createStatement())
|
||||
{
|
||||
del.execute(DELETE_QUERY);
|
||||
|
@ -62,7 +62,7 @@ public final class GrandBossManager implements IStorable
|
||||
|
||||
private void init()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement();
|
||||
ResultSet rs = s.executeQuery("SELECT * from grandboss_data ORDER BY boss_id"))
|
||||
{
|
||||
@ -150,7 +150,7 @@ public final class GrandBossManager implements IStorable
|
||||
@Override
|
||||
public boolean storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
for (Entry<Integer, StatsSet> e : _storedInfo.entrySet())
|
||||
{
|
||||
@ -202,7 +202,7 @@ public final class GrandBossManager implements IStorable
|
||||
|
||||
private void updateDb(int bossId, boolean statusOnly)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
final L2GrandBossInstance boss = _bosses.get(bossId);
|
||||
final StatsSet info = _storedInfo.get(bossId);
|
||||
|
@ -498,7 +498,7 @@ public final class InstanceManager implements IGameXmlReader
|
||||
*/
|
||||
private void restoreInstanceTimes()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement ps = con.createStatement();
|
||||
ResultSet rs = ps.executeQuery("SELECT * FROM character_instance_time ORDER BY charId"))
|
||||
{
|
||||
@ -550,7 +550,7 @@ public final class InstanceManager implements IGameXmlReader
|
||||
// Remove them
|
||||
if (!invalidPenalty.isEmpty())
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
|
||||
{
|
||||
for (Integer id : invalidPenalty)
|
||||
@ -615,7 +615,7 @@ public final class InstanceManager implements IGameXmlReader
|
||||
*/
|
||||
public void deleteInstanceTime(L2PcInstance player, int id)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_INSTANCE_TIME))
|
||||
{
|
||||
ps.setInt(1, player.getObjectId());
|
||||
|
@ -55,7 +55,7 @@ public final class ItemAuctionManager implements IGameXmlReader
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet rset = statement.executeQuery("SELECT auctionId FROM item_auction ORDER BY auctionId DESC LIMIT 0, 1"))
|
||||
{
|
||||
@ -134,7 +134,7 @@ public final class ItemAuctionManager implements IGameXmlReader
|
||||
|
||||
public static void deleteAuction(int auctionId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement statement = con.prepareStatement("DELETE FROM item_auction WHERE auctionId=?"))
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ public final class ItemsOnGroundManager implements Runnable
|
||||
str = "UPDATE itemsonground SET drop_time = ? WHERE drop_time = -1";
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(str))
|
||||
{
|
||||
ps.setLong(1, System.currentTimeMillis());
|
||||
@ -93,7 +93,7 @@ public final class ItemsOnGroundManager implements Runnable
|
||||
}
|
||||
|
||||
// Add items to world
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable FROM itemsonground"))
|
||||
{
|
||||
int count = 0;
|
||||
@ -178,7 +178,7 @@ public final class ItemsOnGroundManager implements Runnable
|
||||
|
||||
public void emptyTable()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s = con.createStatement())
|
||||
{
|
||||
s.executeUpdate("DELETE FROM itemsonground");
|
||||
@ -204,7 +204,7 @@ public final class ItemsOnGroundManager implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) VALUES(?,?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
for (L2ItemInstance item : _items)
|
||||
|
@ -57,7 +57,7 @@ public final class MailManager
|
||||
private void load()
|
||||
{
|
||||
int count = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement ps = con.createStatement();
|
||||
ResultSet rs = ps.executeQuery("SELECT * FROM messages ORDER BY expiration"))
|
||||
{
|
||||
@ -192,7 +192,7 @@ public final class MailManager
|
||||
public void sendMessage(Message msg)
|
||||
{
|
||||
_messages.put(msg.getId(), msg);
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = Message.getStatement(msg, con))
|
||||
{
|
||||
ps.execute();
|
||||
@ -214,7 +214,7 @@ public final class MailManager
|
||||
|
||||
public final void markAsReadInDb(int msgId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE messages SET isUnread = 'false' WHERE messageId = ?"))
|
||||
{
|
||||
ps.setInt(1, msgId);
|
||||
@ -228,7 +228,7 @@ public final class MailManager
|
||||
|
||||
public final void markAsDeletedBySenderInDb(int msgId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE messages SET isDeletedBySender = 'true' WHERE messageId = ?"))
|
||||
{
|
||||
ps.setInt(1, msgId);
|
||||
@ -242,7 +242,7 @@ public final class MailManager
|
||||
|
||||
public final void markAsDeletedByReceiverInDb(int msgId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE messages SET isDeletedByReceiver = 'true' WHERE messageId = ?"))
|
||||
{
|
||||
ps.setInt(1, msgId);
|
||||
@ -256,7 +256,7 @@ public final class MailManager
|
||||
|
||||
public final void removeAttachmentsInDb(int msgId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE messages SET hasAttachments = 'false' WHERE messageId = ?"))
|
||||
{
|
||||
ps.setInt(1, msgId);
|
||||
@ -270,7 +270,7 @@ public final class MailManager
|
||||
|
||||
public final void deleteMessageInDb(int msgId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM messages WHERE messageId = ?"))
|
||||
{
|
||||
ps.setInt(1, msgId);
|
||||
|
@ -54,7 +54,7 @@ public class MentorManager
|
||||
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet rset = statement.executeQuery("SELECT * FROM character_mentees"))
|
||||
{
|
||||
@ -76,7 +76,7 @@ public class MentorManager
|
||||
*/
|
||||
public void deleteMentee(int mentorId, int menteeId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
|
||||
{
|
||||
statement.setInt(1, mentorId);
|
||||
@ -95,7 +95,7 @@ public class MentorManager
|
||||
*/
|
||||
public void deleteMentor(int mentorId, int menteeId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_mentees WHERE mentorId = ? AND charId = ?"))
|
||||
{
|
||||
statement.setInt(1, mentorId);
|
||||
|
@ -128,7 +128,7 @@ public class PremiumManager
|
||||
|
||||
private void loadPremiumData(String accountName)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement(LOAD_SQL))
|
||||
{
|
||||
stmt.setString(1, accountName);
|
||||
@ -160,7 +160,7 @@ public class PremiumManager
|
||||
long newPremiumExpiration = oldPremiumExpiration + addTime;
|
||||
|
||||
// UPDATE DATABASE
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement(UPDATE_SQL))
|
||||
{
|
||||
stmt.setLong(1, newPremiumExpiration);
|
||||
@ -205,7 +205,7 @@ public class PremiumManager
|
||||
premiumData.remove(accountName);
|
||||
|
||||
// UPDATE DATABASE
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stmt = con.prepareStatement(DELETE_SQL))
|
||||
{
|
||||
stmt.setString(1, accountName);
|
||||
|
@ -56,7 +56,7 @@ public final class PunishmentManager
|
||||
int expired = 0;
|
||||
|
||||
// Load punishments.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement st = con.createStatement();
|
||||
ResultSet rset = st.executeQuery("SELECT * FROM punishments"))
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ public final class SiegeGuardManager
|
||||
|
||||
private void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
ResultSet rs = con.createStatement().executeQuery("SELECT * FROM castle_siege_guards Where isHired = 1"))
|
||||
{
|
||||
while (rs.next())
|
||||
@ -158,7 +158,7 @@ public final class SiegeGuardManager
|
||||
final SiegeGuardHolder holder = getSiegeGuardByItem(castle.getResidenceId(), itemId);
|
||||
if (holder != null)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("Insert Into castle_siege_guards (castleId, npcId, x, y, z, heading, respawnDelay, isHired) Values (?, ?, ?, ?, ?, ?, ?, ?)"))
|
||||
{
|
||||
statement.setInt(1, castle.getResidenceId());
|
||||
@ -249,7 +249,7 @@ public final class SiegeGuardManager
|
||||
*/
|
||||
private void loadSiegeGuard(Castle castle)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_siege_guards Where castleId = ? And isHired = ?"))
|
||||
{
|
||||
ps.setInt(1, castle.getResidenceId());
|
||||
@ -283,7 +283,7 @@ public final class SiegeGuardManager
|
||||
*/
|
||||
public void removeSiegeGuard(int npcId, IPositionable pos)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("Delete From castle_siege_guards Where npcId = ? And x = ? AND y = ? AND z = ? AND isHired = 1"))
|
||||
{
|
||||
ps.setInt(1, npcId);
|
||||
@ -304,7 +304,7 @@ public final class SiegeGuardManager
|
||||
*/
|
||||
public void removeSiegeGuards(Castle castle)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("Delete From castle_siege_guards Where castleId = ? And isHired = 1"))
|
||||
{
|
||||
ps.setInt(1, castle.getResidenceId());
|
||||
|
@ -88,7 +88,7 @@ public final class SiegeManager
|
||||
}
|
||||
|
||||
boolean register = false;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT clan_id FROM siege_clans where clan_id=? and castle_id=?"))
|
||||
{
|
||||
statement.setInt(1, clan.getId());
|
||||
@ -275,7 +275,7 @@ public final class SiegeManager
|
||||
|
||||
private void loadTrapUpgrade(int castleId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_trapupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, castleId);
|
||||
|
@ -71,7 +71,7 @@ public class BlockList
|
||||
private static List<Integer> loadList(int ObjId)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=? AND relation=1"))
|
||||
{
|
||||
statement.setInt(1, ObjId);
|
||||
@ -98,7 +98,7 @@ public class BlockList
|
||||
|
||||
private void updateInDB(int targetId, boolean state)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
if (state) // add
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ public class CursedWeapon implements INamable
|
||||
// Remove from Db
|
||||
LOGGER.info(_name + " being removed offline.");
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement del = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET reputation=?, pkkills=? WHERE charId=?"))
|
||||
{
|
||||
@ -471,7 +471,7 @@ public class CursedWeapon implements INamable
|
||||
|
||||
public void saveData()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement del = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO cursed_weapons (itemId, charId, playerReputation, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)"))
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, 0);
|
||||
@ -305,7 +305,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, EnumIntBitmask.getAllBitmask(ClanPrivilege.class));
|
||||
@ -882,7 +882,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
*/
|
||||
public void updateBloodAllianceCountInDB()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_alliance_count=? WHERE clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, _bloodAllianceCount);
|
||||
@ -926,7 +926,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
*/
|
||||
public void updateBloodOathCountInDB()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET blood_oath_count=? WHERE clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, _bloodOathCount);
|
||||
@ -942,7 +942,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
public void updateInDB()
|
||||
{
|
||||
// Update reputation
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET reputation_score=? WHERE clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, _reputationScore);
|
||||
@ -977,7 +977,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
*/
|
||||
public void updateClanInDB()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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());
|
||||
@ -1015,7 +1015,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
*/
|
||||
public void store()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(INSERT_CLAN_DATA))
|
||||
{
|
||||
ps.setInt(1, _clanId);
|
||||
@ -1046,7 +1046,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
*/
|
||||
private void removeMemberInDatabase(L2ClanMember member, long clanJoinExpiryTime, long clanCreateExpiryTime)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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=?"))
|
||||
@ -1071,7 +1071,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
private void restore()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SELECT_CLAN_DATA))
|
||||
{
|
||||
ps.setInt(1, _clanId);
|
||||
@ -1146,7 +1146,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
private void restoreNotice()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT enabled,notice FROM clan_notices WHERE clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, _clanId);
|
||||
@ -1177,7 +1177,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
notice = notice.substring(0, MAX_NOTICE_LENGTH - 1);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_notices (clan_id,notice,enabled) values (?,?,?) ON DUPLICATE KEY UPDATE notice=?,enabled=?"))
|
||||
{
|
||||
ps.setInt(1, _clanId);
|
||||
@ -1236,7 +1236,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
private void restoreSkills()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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
|
||||
@ -1359,7 +1359,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
if (oldSkill != null)
|
||||
{
|
||||
@ -1769,7 +1769,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
private void restoreSubPledges()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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
|
||||
@ -1869,7 +1869,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
return null;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_subpledges (clan_id,sub_pledge_id,name,leader_id) values (?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _clanId);
|
||||
@ -1952,7 +1952,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
public void updateSubPledgeInDB(int pledgeType)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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());
|
||||
@ -1969,7 +1969,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
private void restoreRankPrivs()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT privs,rank,party FROM clan_privs WHERE clan_id=?"))
|
||||
{
|
||||
// Retrieve all skills of this L2PcInstance from the database
|
||||
@ -2018,7 +2018,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
{
|
||||
_privs.get(rank).setPrivs(privs);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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
|
||||
@ -2054,7 +2054,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
{
|
||||
_privs.put(rank, new RankPrivs(rank, 0, privs));
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO clan_privs (clan_id,rank,party,privs) VALUES (?,?,?,?)"))
|
||||
{
|
||||
// Retrieve all skills of this L2PcInstance from the database
|
||||
@ -2173,7 +2173,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
if (storeInDb)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET auction_bid_at=? WHERE clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, id);
|
||||
@ -2716,7 +2716,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
public void changeLevel(int level)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET clan_level = ? WHERE clan_id = ?"))
|
||||
{
|
||||
ps.setInt(1, level);
|
||||
@ -2762,7 +2762,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
setCrestId(crestId);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?"))
|
||||
{
|
||||
ps.setInt(1, crestId);
|
||||
@ -2799,7 +2799,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
allyId = _allyId;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(sqlStatement))
|
||||
{
|
||||
ps.setInt(1, crestId);
|
||||
@ -2845,7 +2845,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
|
||||
setCrestLargeId(crestId);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET crest_large_id = ? WHERE clan_id = ?"))
|
||||
{
|
||||
ps.setInt(1, crestId);
|
||||
|
@ -244,7 +244,7 @@ public class L2ClanMember
|
||||
*/
|
||||
public void updatePledgeType()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET subpledge=? WHERE charId=?"))
|
||||
{
|
||||
ps.setLong(1, _pledgeType);
|
||||
@ -289,7 +289,7 @@ public class L2ClanMember
|
||||
*/
|
||||
public void updatePowerGrade()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET power_grade=? WHERE charId=?"))
|
||||
{
|
||||
ps.setLong(1, _powerGrade);
|
||||
@ -800,7 +800,7 @@ public class L2ClanMember
|
||||
*/
|
||||
public void saveApprenticeAndSponsor(int apprentice, int sponsor)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET apprentice=?,sponsor=? WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, apprentice);
|
||||
|
@ -58,7 +58,7 @@ public class L2ContactList
|
||||
{
|
||||
_contacts.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_LOAD))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
@ -124,7 +124,7 @@ public class L2ContactList
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_ADD))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
@ -161,7 +161,7 @@ public class L2ContactList
|
||||
|
||||
_contacts.remove(name);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(QUERY_REMOVE))
|
||||
{
|
||||
statement.setInt(1, activeChar.getObjectId());
|
||||
|
@ -49,7 +49,7 @@ public class L2Mentee
|
||||
final L2PcInstance player = getPlayerInstance();
|
||||
if (player == null) // Only if player is offline
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT char_name, level, base_class FROM characters WHERE charId = ?"))
|
||||
{
|
||||
statement.setInt(1, _objectId);
|
||||
|
@ -124,7 +124,7 @@ public class MacroList implements IRestorable
|
||||
|
||||
private void registerMacroInDb(Macro macro)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO character_macroses (charId,id,icon,name,descr,acronym,commands) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
@ -160,7 +160,7 @@ public class MacroList implements IRestorable
|
||||
|
||||
private void deleteMacroFromDb(Macro macro)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM character_macroses WHERE charId=? AND id=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
@ -177,7 +177,7 @@ public class MacroList implements IRestorable
|
||||
public boolean restoreMe()
|
||||
{
|
||||
_macroses.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT charId, id, icon, name, descr, acronym, commands FROM character_macroses WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, _owner.getObjectId());
|
||||
|
@ -85,7 +85,7 @@ public class ShortCuts implements IRestorable
|
||||
deleteShortCutFromDb(oldShortCut);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("REPLACE INTO character_shortcuts (charId,slot,page,type,shortcut_id,level,sub_level,class_index) values(?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
@ -154,7 +154,7 @@ public class ShortCuts implements IRestorable
|
||||
*/
|
||||
private void deleteShortCutFromDb(Shortcut shortcut)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
@ -173,7 +173,7 @@ public class ShortCuts implements IRestorable
|
||||
public boolean restoreMe()
|
||||
{
|
||||
_shortCuts.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT charId, slot, page, type, shortcut_id, level, sub_level FROM character_shortcuts WHERE charId=? AND class_index=?"))
|
||||
{
|
||||
statement.setInt(1, _owner.getObjectId());
|
||||
|
@ -1343,7 +1343,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
private void insertNewRecipeData(int recipeId, boolean isDwarf)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO character_recipebook (charId, id, classIndex, type) values(?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -1360,7 +1360,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
private void deleteRecipeData(int recipeId, boolean isDwarf)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_recipebook WHERE charId=? AND id=? AND classIndex=?"))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -6334,7 +6334,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
if (updateInDb)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER_ACCESS))
|
||||
{
|
||||
ps.setInt(1, accessLevel.getLevel());
|
||||
@ -6453,7 +6453,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
public void updateOnlineStatus()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE charId=?"))
|
||||
{
|
||||
statement.setInt(1, isOnlineInt());
|
||||
@ -6473,7 +6473,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private boolean createDb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(INSERT_CHARACTER))
|
||||
{
|
||||
statement.setString(1, _accountName);
|
||||
@ -6537,7 +6537,7 @@ public final class L2PcInstance extends L2Playable
|
||||
double currentCp = 0;
|
||||
double currentHp = 0;
|
||||
double currentMp = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER))
|
||||
{
|
||||
// Retrieve the L2PcInstance from the characters table of the database
|
||||
@ -6898,7 +6898,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private static boolean restoreSubClassData(L2PcInstance player)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_SUBCLASSES))
|
||||
{
|
||||
statement.setInt(1, player.getObjectId());
|
||||
@ -6989,7 +6989,7 @@ public final class L2PcInstance extends L2Playable
|
||||
private void restoreRecipeBook(boolean loadCommon)
|
||||
{
|
||||
final String sql = loadCommon ? "SELECT id, type, classIndex FROM character_recipebook WHERE charId=?" : "SELECT id FROM character_recipebook WHERE charId=? AND classIndex=? AND type = 1";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(sql))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -7042,7 +7042,7 @@ public final class L2PcInstance extends L2Playable
|
||||
private void loadPremiumItemList()
|
||||
{
|
||||
final String sql = "SELECT itemNum, itemId, itemCount, itemSender FROM character_premium_items WHERE charId=?";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(sql))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -7066,7 +7066,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
public void updatePremiumItem(int itemNum, long newcount)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE character_premium_items SET itemCount=? WHERE charId=? AND itemNum=? "))
|
||||
{
|
||||
statement.setLong(1, newcount);
|
||||
@ -7082,7 +7082,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
public void deletePremiumItem(int itemNum)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_premium_items WHERE charId=? AND itemNum=? "))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -7135,7 +7135,7 @@ public final class L2PcInstance extends L2Playable
|
||||
final long exp = getStat().getBaseExp();
|
||||
final int level = getStat().getBaseLevel();
|
||||
final long sp = getStat().getBaseSp();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER))
|
||||
{
|
||||
statement.setInt(1, level);
|
||||
@ -7220,7 +7220,7 @@ public final class L2PcInstance extends L2Playable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_CHAR_SUBCLASS))
|
||||
{
|
||||
for (SubClass subClass : getSubClasses().values())
|
||||
@ -7251,7 +7251,7 @@ public final class L2PcInstance extends L2Playable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement delete = con.prepareStatement(DELETE_SKILL_SAVE);
|
||||
PreparedStatement statement = con.prepareStatement(ADD_SKILL_SAVE))
|
||||
{
|
||||
@ -7371,7 +7371,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
private void storeItemReuseDelay()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
|
||||
PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE))
|
||||
{
|
||||
@ -7488,7 +7488,7 @@ public final class L2PcInstance extends L2Playable
|
||||
final Skill oldSkill = super.removeSkill(skill, true);
|
||||
if (oldSkill != null)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
|
||||
{
|
||||
// Remove or update a L2PcInstance skill from the character_skills table of the database
|
||||
@ -7531,7 +7531,7 @@ public final class L2PcInstance extends L2Playable
|
||||
private void storeSkill(Skill newSkill, Skill oldSkill, int newClassIndex)
|
||||
{
|
||||
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
if ((oldSkill != null) && (newSkill != null))
|
||||
{
|
||||
@ -7581,7 +7581,7 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
|
||||
final int classIndex = (newClassIndex > -1) ? newClassIndex : _classIndex;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ADD_NEW_SKILLS))
|
||||
{
|
||||
con.setAutoCommit(false);
|
||||
@ -7608,7 +7608,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private void restoreSkills()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
|
||||
{
|
||||
// Retrieve all skills of this L2PcInstance from the database
|
||||
@ -7660,7 +7660,7 @@ public final class L2PcInstance extends L2Playable
|
||||
@Override
|
||||
public void restoreEffects()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_SKILL_SAVE))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -7717,7 +7717,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private void restoreItemReuse()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
|
||||
PreparedStatement delete = con.prepareStatement(DELETE_ITEM_REUSE_SAVE))
|
||||
{
|
||||
@ -7788,7 +7788,7 @@ public final class L2PcInstance extends L2Playable
|
||||
_henna[i - 1] = null;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -7896,7 +7896,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
_henna[slot - 1] = null;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -7994,7 +7994,7 @@ public final class L2PcInstance extends L2Playable
|
||||
// Calculate Henna modifiers of this L2PcInstance
|
||||
recalcHennaStats();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -9631,7 +9631,7 @@ public final class L2PcInstance extends L2Playable
|
||||
newClass.setLevel(Config.BASE_DUALCLASS_LEVEL);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS))
|
||||
{
|
||||
// Store the basic info about this new sub-class.
|
||||
@ -9731,7 +9731,7 @@ public final class L2PcInstance extends L2Playable
|
||||
// Remove after stats are recalculated.
|
||||
getSubClasses().remove(classIndex);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement deleteHennas = con.prepareStatement(DELETE_CHAR_HENNAS);
|
||||
PreparedStatement deleteShortcuts = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
|
||||
PreparedStatement deleteSkillReuse = con.prepareStatement(DELETE_SKILL_SAVE);
|
||||
@ -11968,7 +11968,7 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
String req;
|
||||
req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(req))
|
||||
{
|
||||
statement.setInt(1, _curFeed);
|
||||
@ -12095,7 +12095,7 @@ public final class L2PcInstance extends L2Playable
|
||||
bookmark.setTag(tag);
|
||||
bookmark.setName(name);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK))
|
||||
{
|
||||
statement.setInt(1, icon);
|
||||
@ -12118,7 +12118,7 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
if (_tpbookmarks.remove(id) != null)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -12261,7 +12261,7 @@ public final class L2PcInstance extends L2Playable
|
||||
sm.addItemName(20033);
|
||||
sendPacket(sm);
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -12283,7 +12283,7 @@ public final class L2PcInstance extends L2Playable
|
||||
|
||||
public void restoreTeleportBookmark()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -12495,7 +12495,7 @@ public final class L2PcInstance extends L2Playable
|
||||
_friendList.clear();
|
||||
|
||||
final String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(sqlQuery))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -12585,7 +12585,7 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
if (hasManufactureShop())
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_CHAR_RECIPE_SHOP))
|
||||
{
|
||||
@ -12623,7 +12623,7 @@ public final class L2PcInstance extends L2Playable
|
||||
_manufactureItems.clear();
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_RECIPE_SHOP))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -13041,7 +13041,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private void restorePetInventoryItems()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -13081,7 +13081,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
private void loadRecommendations()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT rec_have, rec_left FROM character_reco_bonus WHERE charId = ?"))
|
||||
{
|
||||
statement.setInt(1, getObjectId());
|
||||
@ -13105,7 +13105,7 @@ public final class L2PcInstance extends L2Playable
|
||||
*/
|
||||
public void storeRecommendations()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getObjectId());
|
||||
|
@ -788,7 +788,7 @@ public class L2PetInstance extends L2Summon
|
||||
}
|
||||
|
||||
// pet control item no longer exists, delete the pet from the db
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
|
||||
{
|
||||
statement.setInt(1, _controlObjectId);
|
||||
@ -846,7 +846,7 @@ public class L2PetInstance extends L2Summon
|
||||
|
||||
private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?"))
|
||||
{
|
||||
L2PetInstance pet;
|
||||
@ -942,7 +942,7 @@ 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 = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(req))
|
||||
{
|
||||
statement.setString(1, getName());
|
||||
@ -992,7 +992,7 @@ public class L2PetInstance extends L2Summon
|
||||
// Clear list for overwrite
|
||||
SummonEffectsTable.getInstance().getPetEffects().getOrDefault(getControlObjectId(), Collections.emptyList()).clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
|
||||
PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
|
||||
{
|
||||
@ -1067,7 +1067,7 @@ public class L2PetInstance extends L2Summon
|
||||
@Override
|
||||
public void restoreEffects()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
|
||||
PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
|
||||
{
|
||||
|
@ -288,7 +288,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
|
||||
SummonEffectsTable.getInstance().getServitorEffects(getOwner()).getOrDefault(getReferenceSkill(), Collections.emptyList()).clear();
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
|
||||
{
|
||||
// Delete all current stored effects for summon to avoid dupe
|
||||
@ -389,7 +389,7 @@ public class L2ServitorInstance extends L2Summon implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().containsKey(getOwner().getObjectId()) || !SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).containsKey(getOwner().getClassIndex()) || !SummonEffectsTable.getInstance().getServitorEffects(getOwner()).containsKey(getReferenceSkill()))
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ public class Announcement implements IAnnouncement
|
||||
@Override
|
||||
public boolean storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
|
||||
{
|
||||
ps.setInt(1, _type.ordinal());
|
||||
@ -134,7 +134,7 @@ public class Announcement implements IAnnouncement
|
||||
@Override
|
||||
public boolean updateMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(UPDATE_QUERY))
|
||||
{
|
||||
ps.setInt(1, _type.ordinal());
|
||||
@ -154,7 +154,7 @@ public class Announcement implements IAnnouncement
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_QUERY))
|
||||
{
|
||||
ps.setInt(1, _id);
|
||||
|
@ -94,7 +94,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
|
||||
@Override
|
||||
public boolean storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
|
||||
{
|
||||
st.setInt(1, getType().ordinal());
|
||||
@ -123,7 +123,7 @@ public final class AutoAnnouncement extends Announcement implements Runnable
|
||||
@Override
|
||||
public boolean updateMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
|
||||
{
|
||||
st.setInt(1, getType().ordinal());
|
||||
|
@ -157,7 +157,7 @@ public final class Product
|
||||
|
||||
private void save()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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` = ?"))
|
||||
{
|
||||
statement.setInt(1, _buyListId);
|
||||
|
@ -58,7 +58,7 @@ public class ClanHallAuction
|
||||
|
||||
private final void loadBidder()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(LOAD_CLANHALL_BIDDERS))
|
||||
{
|
||||
ps.setInt(1, _clanHallId);
|
||||
@ -102,7 +102,7 @@ public class ClanHallAuction
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(INSERT_CLANHALL_BIDDER))
|
||||
{
|
||||
ps.setInt(1, _clanHallId);
|
||||
@ -121,7 +121,7 @@ public class ClanHallAuction
|
||||
public void removeBid(L2Clan clan)
|
||||
{
|
||||
getBids().remove(clan.getId());
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_CLANHALL_BIDDER))
|
||||
{
|
||||
ps.setInt(1, clan.getId());
|
||||
@ -170,7 +170,7 @@ public class ClanHallAuction
|
||||
clanHall.setOwner(highestBidder.getClan());
|
||||
getBids().clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_CLANHALL_BIDDERS))
|
||||
{
|
||||
ps.setInt(1, _clanHallId);
|
||||
|
@ -218,7 +218,7 @@ public final class Castle extends AbstractResidence
|
||||
|
||||
public void dbSave()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_functions (castle_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -360,7 +360,7 @@ public final class Castle extends AbstractResidence
|
||||
_treasury += amount;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET treasury = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setLong(1, _treasury);
|
||||
@ -643,7 +643,7 @@ public final class Castle extends AbstractResidence
|
||||
@Override
|
||||
protected void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement("SELECT * FROM castle WHERE id = ?");
|
||||
PreparedStatement ps2 = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ?"))
|
||||
{
|
||||
@ -689,7 +689,7 @@ public final class Castle extends AbstractResidence
|
||||
/** Load All Functions */
|
||||
private void loadFunctions()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_functions WHERE castle_id = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -714,7 +714,7 @@ public final class Castle extends AbstractResidence
|
||||
public void removeFunction(int functionType)
|
||||
{
|
||||
_function.remove(functionType);
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_functions WHERE castle_id=? AND type=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -786,7 +786,7 @@ public final class Castle extends AbstractResidence
|
||||
// This method loads castle door upgrade data from database
|
||||
private void loadDoorUpgrade()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM castle_doorupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -812,7 +812,7 @@ public final class Castle extends AbstractResidence
|
||||
door.setCurrentHp(door.getCurrentHp());
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_doorupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -837,7 +837,7 @@ public final class Castle extends AbstractResidence
|
||||
|
||||
if (save)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_doorupgrade (doorId, ratio, castleId) values (?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, doorId);
|
||||
@ -864,7 +864,7 @@ public final class Castle extends AbstractResidence
|
||||
CastleManorManager.getInstance().resetManorData(getResidenceId());
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.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 = ?"))
|
||||
@ -1032,7 +1032,7 @@ public final class Castle extends AbstractResidence
|
||||
|
||||
public void updateShowNpcCrest()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setString(1, String.valueOf(_showNpcCrest));
|
||||
@ -1076,7 +1076,7 @@ public final class Castle extends AbstractResidence
|
||||
{
|
||||
_ticketBuyCount = count;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET ticketBuyCount = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _ticketBuyCount);
|
||||
@ -1099,7 +1099,7 @@ public final class Castle extends AbstractResidence
|
||||
{
|
||||
if (save)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO castle_trapupgrade (castleId, towerIndex, level) values (?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1126,7 +1126,7 @@ public final class Castle extends AbstractResidence
|
||||
ts.setUpgradeLevel(0);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM castle_trapupgrade WHERE castleId=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1209,7 +1209,7 @@ public final class Castle extends AbstractResidence
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE castle SET side = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setString(1, side.toString());
|
||||
|
@ -100,7 +100,7 @@ public final class ClanHall extends AbstractResidence
|
||||
@Override
|
||||
protected void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement loadStatement = con.prepareStatement(LOAD_CLANHALL);
|
||||
PreparedStatement insertStatement = con.prepareStatement(INSERT_CLANHALL))
|
||||
{
|
||||
@ -133,7 +133,7 @@ public final class ClanHall extends AbstractResidence
|
||||
|
||||
public void updateDB()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_CLANHALL))
|
||||
{
|
||||
statement.setInt(1, getOwnerId());
|
||||
|
@ -45,7 +45,7 @@ public class Couple
|
||||
{
|
||||
_Id = coupleId;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM mods_wedding WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _Id);
|
||||
@ -85,7 +85,7 @@ public class Couple
|
||||
_weddingDate = Calendar.getInstance();
|
||||
_weddingDate.setTimeInMillis(Calendar.getInstance().getTimeInMillis());
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO mods_wedding (id, player1Id, player2Id, married, affianceDate, weddingDate) VALUES (?, ?, ?, ?, ?, ?)"))
|
||||
{
|
||||
_Id = IdFactory.getInstance().getNextId();
|
||||
@ -105,7 +105,7 @@ public class Couple
|
||||
|
||||
public void marry()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE mods_wedding set married = ?, weddingDate = ? where id = ?"))
|
||||
{
|
||||
ps.setBoolean(1, true);
|
||||
@ -123,7 +123,7 @@ public class Couple
|
||||
|
||||
public void divorce()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM mods_wedding WHERE id=?"))
|
||||
{
|
||||
ps.setInt(1, _Id);
|
||||
|
@ -214,7 +214,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
public void dbSave()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("REPLACE INTO fort_functions (fort_id, type, lvl, lease, rate, endTime) VALUES (?,?,?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -487,7 +487,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
public void saveFortVariables()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET supplyLvL=? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _supplyLvL);
|
||||
@ -552,7 +552,7 @@ public final class Fort extends AbstractResidence
|
||||
@Override
|
||||
protected void load()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -613,7 +613,7 @@ public final class Fort extends AbstractResidence
|
||||
/** Load All Functions */
|
||||
private void loadFunctions()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_functions WHERE fort_id = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -638,7 +638,7 @@ public final class Fort extends AbstractResidence
|
||||
public void removeFunction(int functionType)
|
||||
{
|
||||
_function.remove(functionType);
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_functions WHERE fort_id=? AND type=?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -730,7 +730,7 @@ public final class Fort extends AbstractResidence
|
||||
// This method loads fort door upgrade data from database
|
||||
private void loadDoorUpgrade()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_doorupgrade WHERE fortId = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -750,7 +750,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
private void removeDoorUpgrade()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM fort_doorupgrade WHERE fortId = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -764,7 +764,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
private void saveDoorUpgrade(int doorId, int hp, int pDef, int mDef)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO fort_doorupgrade (doorId, hp, pDef, mDef) VALUES (?,?,?,?)"))
|
||||
{
|
||||
ps.setInt(1, doorId);
|
||||
@ -793,7 +793,7 @@ public final class Fort extends AbstractResidence
|
||||
_lastOwnedTime.setTimeInMillis(0);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET owner=?,lastOwnedTime=?,state=?,castleId=? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, clanId);
|
||||
@ -998,7 +998,7 @@ public final class Fort extends AbstractResidence
|
||||
{
|
||||
_state = state;
|
||||
_castleId = castleId;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET state=?,castleId=? WHERE id = ?"))
|
||||
{
|
||||
ps.setInt(1, _state);
|
||||
@ -1130,7 +1130,7 @@ public final class Fort extends AbstractResidence
|
||||
|
||||
private void initNpcs()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM fort_spawnlist WHERE fortId = ? AND spawnType = ?"))
|
||||
{
|
||||
ps.setInt(1, getResidenceId());
|
||||
@ -1159,7 +1159,7 @@ public final class Fort extends AbstractResidence
|
||||
private void initSiegeNpcs()
|
||||
{
|
||||
_siegeNpcs.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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());
|
||||
@ -1186,7 +1186,7 @@ public final class Fort extends AbstractResidence
|
||||
private void initNpcCommanders()
|
||||
{
|
||||
_npcCommanders.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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());
|
||||
@ -1216,7 +1216,7 @@ public final class Fort extends AbstractResidence
|
||||
_specialEnvoys.clear();
|
||||
_envoyCastles.clear();
|
||||
_availableCastles.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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());
|
||||
|
@ -501,7 +501,7 @@ public class FortSiege implements Siegable
|
||||
/** Clear all registered siege clans from database for fort */
|
||||
public void clearSiegeClan()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM fortsiege_clans WHERE fort_id=?"))
|
||||
{
|
||||
ps.setInt(1, _fort.getResidenceId());
|
||||
@ -785,7 +785,7 @@ 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 = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(query))
|
||||
{
|
||||
statement.setInt(1, _fort.getResidenceId());
|
||||
@ -999,7 +999,7 @@ public class FortSiege implements Siegable
|
||||
private void loadSiegeClan()
|
||||
{
|
||||
_attackerClans.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT clan_id FROM fortsiege_clans WHERE fort_id=?"))
|
||||
{
|
||||
ps.setInt(1, _fort.getResidenceId());
|
||||
@ -1057,7 +1057,7 @@ public class FortSiege implements Siegable
|
||||
/** Save siege date to database. */
|
||||
private void saveSiegeDate()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE fort SET siegeDate = ? WHERE id = ?"))
|
||||
{
|
||||
ps.setLong(1, _fort.getSiegeDate().getTimeInMillis());
|
||||
@ -1081,7 +1081,7 @@ public class FortSiege implements Siegable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO fortsiege_clans (clan_id,fort_id) values (?,?)"))
|
||||
{
|
||||
statement.setInt(1, clan.getId());
|
||||
@ -1146,7 +1146,7 @@ public class FortSiege implements Siegable
|
||||
public void loadSiegeGuard()
|
||||
{
|
||||
_siegeGuards.clear();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT npcId, x, y, z, heading, respawnDelay FROM fort_siege_guards WHERE fortId = ?"))
|
||||
{
|
||||
final int fortId = _fort.getResidenceId();
|
||||
|
@ -114,7 +114,7 @@ public class Hero
|
||||
_herodiary.clear();
|
||||
_heroMessage.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
Statement s1 = con.createStatement();
|
||||
ResultSet rset = s1.executeQuery(GET_HEROES);
|
||||
PreparedStatement ps = con.prepareStatement(GET_CLAN_ALLY);
|
||||
@ -211,7 +211,7 @@ public class Hero
|
||||
*/
|
||||
public void loadMessage(int charId)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT message FROM heroes WHERE charId=?"))
|
||||
{
|
||||
statement.setInt(1, charId);
|
||||
@ -233,7 +233,7 @@ public class Hero
|
||||
{
|
||||
final List<StatsSet> _diary = new CopyOnWriteArrayList<>();
|
||||
int diaryentries = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM heroes_diary WHERE charId=? ORDER BY time ASC"))
|
||||
{
|
||||
statement.setInt(1, charId);
|
||||
@ -300,7 +300,7 @@ public class Hero
|
||||
int _losses = 0;
|
||||
int _draws = 0;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) AND start<? ORDER BY start ASC"))
|
||||
{
|
||||
statement.setInt(1, charId);
|
||||
@ -699,7 +699,7 @@ public class Hero
|
||||
|
||||
public void updateHeroes(boolean setDefault)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
if (setDefault)
|
||||
{
|
||||
@ -841,7 +841,7 @@ public class Hero
|
||||
|
||||
public void setDiaryData(int charId, int action, int param)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO heroes_diary (charId, time, action, param) values(?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, charId);
|
||||
@ -877,7 +877,7 @@ public class Hero
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE heroes SET message=? WHERE charId=?;"))
|
||||
{
|
||||
statement.setString(1, _heroMessage.get(charId));
|
||||
@ -892,7 +892,7 @@ public class Hero
|
||||
|
||||
private void deleteItemsInDb()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(DELETE_ITEMS))
|
||||
{
|
||||
statement.execute();
|
||||
|
@ -760,7 +760,7 @@ public class Siege implements Siegable
|
||||
/** Clear all registered siege clans from database for castle */
|
||||
public void clearSiegeClan()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=?"))
|
||||
{
|
||||
statement.setInt(1, _castle.getResidenceId());
|
||||
@ -788,7 +788,7 @@ public class Siege implements Siegable
|
||||
/** Clear all siege clans waiting for approval from database for castle */
|
||||
public void clearSiegeWaitingClan()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and type = 2"))
|
||||
{
|
||||
statement.setInt(1, _castle.getResidenceId());
|
||||
@ -972,7 +972,7 @@ public class Siege implements Siegable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM siege_clans WHERE castle_id=? and clan_id=?"))
|
||||
{
|
||||
statement.setInt(1, _castle.getResidenceId());
|
||||
@ -1238,7 +1238,7 @@ public class Siege implements Siegable
|
||||
private void loadSiegeClan()
|
||||
{
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT clan_id,type FROM siege_clans where castle_id=?"))
|
||||
{
|
||||
getAttackerClans().clear();
|
||||
@ -1349,7 +1349,7 @@ public class Siege implements Siegable
|
||||
_scheduledStartSiegeTask = ThreadPool.schedule(new ScheduleStartSiegeTask(_castle), 1000);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE castle SET siegeDate = ?, regTimeEnd = ?, regTimeOver = ? WHERE id = ?"))
|
||||
{
|
||||
statement.setLong(1, _castle.getSiegeDate().getTimeInMillis());
|
||||
@ -1378,7 +1378,7 @@ public class Siege implements Siegable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
if ((typeId == DEFENDER) || (typeId == DEFENDER_NOT_APPROVED) || (typeId == OWNER))
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ public class EventScheduler
|
||||
|
||||
public boolean updateLastRun()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO event_schedulers (eventName, schedulerName, lastRun) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE eventName = ?, schedulerName = ?, lastRun = ?"))
|
||||
{
|
||||
ps.setString(1, _eventManager.getName());
|
||||
|
@ -52,7 +52,7 @@ public class HaventRunConditionalScheduler implements IConditionalEventScheduler
|
||||
throw new NullPointerException("Scheduler not found: " + _name);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT lastRun FROM event_schedulers WHERE eventName = ? AND schedulerName = ?"))
|
||||
{
|
||||
ps.setString(1, _eventManager.getName());
|
||||
|
@ -815,7 +815,7 @@ public final class Instance implements IIdentifiable, INamable
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT IGNORE INTO character_instance_time (charId,instanceId,time) VALUES (?,?,?)"))
|
||||
{
|
||||
// Save to database
|
||||
|
@ -191,7 +191,7 @@ public final class ItemAuction
|
||||
|
||||
public final void storeMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO item_auction (auctionId,instanceId,auctionItemId,startingTime,endingTime,auctionStateId) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE auctionStateId=?"))
|
||||
{
|
||||
statement.setInt(1, _auctionId);
|
||||
@ -225,7 +225,7 @@ public final class ItemAuction
|
||||
final void updatePlayerBidInternal(ItemAuctionBid bid, boolean delete)
|
||||
{
|
||||
final String query = delete ? DELETE_ITEM_AUCTION_BID : INSERT_ITEM_AUCTION_BID;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(query))
|
||||
{
|
||||
ps.setInt(1, _auctionId);
|
||||
|
@ -161,7 +161,7 @@ public final class ItemAuctionInstance
|
||||
throw new IllegalArgumentException("No items defined");
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SELECT_AUCTION_ID_BY_INSTANCE_ID))
|
||||
{
|
||||
ps.setInt(1, _instanceId);
|
||||
@ -533,7 +533,7 @@ public final class ItemAuctionInstance
|
||||
|
||||
private ItemAuction loadAuction(int auctionId) throws SQLException
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
int auctionItemId = 0;
|
||||
long startingTime = 0;
|
||||
|
@ -1783,7 +1783,7 @@ public abstract class Inventory extends ItemContainer
|
||||
@Override
|
||||
public void restore()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data"))
|
||||
{
|
||||
ps.setInt(1, getOwnerId());
|
||||
|
@ -673,7 +673,7 @@ public abstract class ItemContainer
|
||||
*/
|
||||
public void restore()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND (loc=?)"))
|
||||
{
|
||||
ps.setInt(1, getOwnerId());
|
||||
|
@ -112,7 +112,7 @@ public class Mail extends ItemContainer
|
||||
@Override
|
||||
public void restore()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM items WHERE owner_id=? AND loc=? AND loc_data=?"))
|
||||
{
|
||||
statement.setInt(1, _ownerId);
|
||||
|
@ -738,7 +738,7 @@ public class PcInventory extends Inventory
|
||||
public static int[][] restoreVisibleInventory(int objectId)
|
||||
{
|
||||
final int[][] paperdoll = new int[33][4];
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement2 = con.prepareStatement("SELECT object_id,item_id,loc_data,enchant_level FROM items WHERE owner_id=? AND loc='PAPERDOLL'"))
|
||||
{
|
||||
statement2.setInt(1, objectId);
|
||||
|
@ -976,7 +976,7 @@ public final class L2ItemInstance extends L2Object
|
||||
final VariationInstance augment = _augmentation;
|
||||
_augmentation = null;
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId = ?"))
|
||||
{
|
||||
ps.setInt(1, getObjectId());
|
||||
@ -993,7 +993,7 @@ public final class L2ItemInstance extends L2Object
|
||||
|
||||
public void restoreAttributes()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement("SELECT mineralId,option1,option2 FROM item_variations WHERE itemId=?");
|
||||
PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
|
||||
{
|
||||
@ -1034,7 +1034,7 @@ public final class L2ItemInstance extends L2Object
|
||||
|
||||
public void updateItemOptions()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
updateItemOptions(con);
|
||||
}
|
||||
@ -1062,7 +1062,7 @@ public final class L2ItemInstance extends L2Object
|
||||
|
||||
public void updateItemElementals()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
updateItemElements(con);
|
||||
}
|
||||
@ -1224,7 +1224,7 @@ public final class L2ItemInstance extends L2Object
|
||||
_elementals.remove(type);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?"))
|
||||
{
|
||||
ps.setInt(1, getObjectId());
|
||||
@ -1249,7 +1249,7 @@ public final class L2ItemInstance extends L2Object
|
||||
_elementals.clear();
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ?"))
|
||||
{
|
||||
ps.setInt(1, getObjectId());
|
||||
@ -1581,7 +1581,7 @@ public final class L2ItemInstance extends L2Object
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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);
|
||||
@ -1614,7 +1614,7 @@ public final class L2ItemInstance extends L2Object
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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);
|
||||
@ -1658,7 +1658,7 @@ public final class L2ItemInstance extends L2Object
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM items WHERE object_id = ?"))
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ public class Olympiad extends ListenersContainer
|
||||
{
|
||||
_nobles.clear();
|
||||
boolean loaded = false;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_DATA);
|
||||
ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
@ -221,7 +221,7 @@ public class Olympiad extends ListenersContainer
|
||||
}
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_LOAD_NOBLES);
|
||||
ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
@ -295,7 +295,7 @@ public class Olympiad extends ListenersContainer
|
||||
{
|
||||
_noblesRank.clear();
|
||||
final Map<Integer, Integer> tmpPlace = new HashMap<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS);
|
||||
ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
@ -806,7 +806,7 @@ public class Olympiad extends ListenersContainer
|
||||
return;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
for (Entry<Integer, StatsSet> entry : _nobles.entrySet())
|
||||
{
|
||||
@ -878,7 +878,7 @@ public class Olympiad extends ListenersContainer
|
||||
{
|
||||
saveNobleData();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA))
|
||||
{
|
||||
statement.setInt(1, _currentCycle);
|
||||
@ -919,7 +919,7 @@ public class Olympiad extends ListenersContainer
|
||||
|
||||
protected void updateMonthlyData()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps1 = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
|
||||
PreparedStatement ps2 = con.prepareStatement(OLYMPIAD_MONTH_CREATE))
|
||||
{
|
||||
@ -963,7 +963,7 @@ public class Olympiad extends ListenersContainer
|
||||
|
||||
final List<StatsSet> heroesToBe = new LinkedList<>();
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_GET_HEROS))
|
||||
{
|
||||
StatsSet hero;
|
||||
@ -998,7 +998,7 @@ public class Olympiad extends ListenersContainer
|
||||
{
|
||||
final List<String> names = new ArrayList<>();
|
||||
final 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 = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(query))
|
||||
{
|
||||
ps.setInt(1, classId);
|
||||
@ -1108,7 +1108,7 @@ public class Olympiad extends ListenersContainer
|
||||
public int getLastNobleOlympiadPoints(int objId)
|
||||
{
|
||||
int result = 0;
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?"))
|
||||
{
|
||||
ps.setInt(1, objId);
|
||||
@ -1252,7 +1252,7 @@ public class Olympiad extends ListenersContainer
|
||||
|
||||
protected void deleteNobles()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL))
|
||||
{
|
||||
statement.execute();
|
||||
|
@ -743,7 +743,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, one.getObjectId());
|
||||
|
@ -185,7 +185,7 @@ public class PunishmentTask implements Runnable
|
||||
{
|
||||
if (!_isStored)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(INSERT_QUERY, Statement.RETURN_GENERATED_KEYS))
|
||||
{
|
||||
st.setString(1, _key);
|
||||
@ -224,7 +224,7 @@ public class PunishmentTask implements Runnable
|
||||
{
|
||||
if (_isStored)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(UPDATE_QUERY))
|
||||
{
|
||||
st.setLong(1, System.currentTimeMillis());
|
||||
|
@ -409,7 +409,7 @@ public class LongTimeEvent extends Quest
|
||||
}
|
||||
}
|
||||
// Update database
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE item_id=?"))
|
||||
{
|
||||
statement.setInt(1, itemId);
|
||||
|
@ -1589,7 +1589,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
*/
|
||||
public static void playerEnter(L2PcInstance player)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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 = ?"))
|
||||
@ -1671,7 +1671,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
*/
|
||||
public static void createQuestVarInDb(QuestState qs, String var, String value)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO character_quests (charId,name,var,value) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE value=?"))
|
||||
{
|
||||
statement.setInt(1, qs.getPlayer().getObjectId());
|
||||
@ -1695,7 +1695,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
*/
|
||||
public static void updateQuestVarInDb(QuestState qs, String var, String value)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE character_quests SET value=? WHERE charId=? AND name=? AND var = ?"))
|
||||
{
|
||||
statement.setString(1, value);
|
||||
@ -1717,7 +1717,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
*/
|
||||
public static void deleteQuestVarInDb(QuestState qs, String var)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE charId=? AND name=? AND var=?"))
|
||||
{
|
||||
statement.setInt(1, qs.getPlayer().getObjectId());
|
||||
@ -1738,7 +1738,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
*/
|
||||
public static void deleteQuestInDb(QuestState qs, boolean repeatable)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.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());
|
||||
|
@ -126,7 +126,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
|
||||
*/
|
||||
protected void initFunctions()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM residence_functions WHERE residenceId = ?"))
|
||||
{
|
||||
ps.setInt(1, _residenceId);
|
||||
@ -164,7 +164,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
|
||||
*/
|
||||
public void addFunction(ResidenceFunction func)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO residence_functions (id, level, expiration, residenceId) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE level = ?, expiration = ?"))
|
||||
{
|
||||
ps.setInt(1, func.getId());
|
||||
@ -196,7 +196,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
|
||||
*/
|
||||
public void removeFunction(ResidenceFunction func)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ? and id = ?"))
|
||||
{
|
||||
ps.setInt(1, _residenceId);
|
||||
@ -219,7 +219,7 @@ public abstract class AbstractResidence extends ListenersContainer implements IN
|
||||
*/
|
||||
public void removeFunctions()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("DELETE FROM residence_functions WHERE residenceId = ?"))
|
||||
{
|
||||
ps.setInt(1, _residenceId);
|
||||
|
@ -50,7 +50,7 @@ public class AccountVariables extends AbstractVariables
|
||||
public boolean restoreMe()
|
||||
{
|
||||
// Restore previous variables.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(SELECT_QUERY))
|
||||
{
|
||||
st.setString(1, _accountName);
|
||||
@ -83,7 +83,7 @@ public class AccountVariables extends AbstractVariables
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// Clear previous entries.
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
|
||||
@ -120,7 +120,7 @@ public class AccountVariables extends AbstractVariables
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// Clear previous entries.
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
|
||||
|
@ -50,7 +50,7 @@ public class ClanVariables extends AbstractVariables
|
||||
public boolean restoreMe()
|
||||
{
|
||||
// Restore previous variables.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(SELECT_QUERY))
|
||||
{
|
||||
st.setInt(1, _objectId);
|
||||
@ -83,7 +83,7 @@ public class ClanVariables extends AbstractVariables
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// Clear previous entries.
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
|
||||
@ -120,7 +120,7 @@ public class ClanVariables extends AbstractVariables
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// Clear previous entries.
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
|
||||
|
@ -55,7 +55,7 @@ public class ItemVariables extends AbstractVariables
|
||||
public static boolean hasVariables(int objectId)
|
||||
{
|
||||
// Restore previous variables.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(SELECT_COUNT))
|
||||
{
|
||||
st.setInt(1, objectId);
|
||||
@ -79,7 +79,7 @@ public class ItemVariables extends AbstractVariables
|
||||
public boolean restoreMe()
|
||||
{
|
||||
// Restore previous variables.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement st = con.prepareStatement(SELECT_QUERY))
|
||||
{
|
||||
st.setInt(1, _objectId);
|
||||
@ -112,7 +112,7 @@ public class ItemVariables extends AbstractVariables
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// Clear previous entries.
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
|
||||
@ -149,7 +149,7 @@ public class ItemVariables extends AbstractVariables
|
||||
@Override
|
||||
public boolean deleteMe()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
// Clear previous entries.
|
||||
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user