Sync with L2jServer HighFive Jul 25th 2015.
This commit is contained in:
@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2AccessLevel;
|
||||
@@ -75,15 +75,14 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
|
||||
statement.setInt(1, lvl);
|
||||
statement.setString(2, name);
|
||||
statement.execute();
|
||||
int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
if (count == 0)
|
||||
ps.setInt(1, lvl);
|
||||
ps.setString(2, name);
|
||||
ps.execute();
|
||||
|
||||
if (ps.getUpdateCount() == 0)
|
||||
{
|
||||
activeChar.sendMessage("Character not found or access level unaltered.");
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jserver.gameserver.data.xml.impl.ClassListData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
@@ -557,11 +557,13 @@ public class AdminEditChar implements IAdminCommandHandler
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
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);
|
||||
ps.execute();
|
||||
final String updateQuery = "UPDATE characters SET " + (changeCreateExpiryTime ? "clan_create_expiry_time" : "clan_join_expiry_time") + " WHERE char_name=? LIMIT 1";
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(updateQuery))
|
||||
{
|
||||
ps.setString(1, playerName);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -20,11 +20,11 @@ package handlers.admincommandhandlers;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
@@ -63,47 +63,36 @@ public class AdminRepairChar implements IAdminCommandHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerName = parts[1];
|
||||
String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(cmd);
|
||||
statement.setString(1, parts[1]);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
statement = con.prepareStatement("SELECT charId FROM characters where char_name=?");
|
||||
statement.setString(1, parts[1]);
|
||||
ResultSet rset = statement.executeQuery();
|
||||
int objId = 0;
|
||||
if (rset.next())
|
||||
try (PreparedStatement ps = con.prepareStatement(cmd))
|
||||
{
|
||||
objId = rset.getInt(1);
|
||||
ps.setString(1, playerName);
|
||||
ps.execute();
|
||||
}
|
||||
|
||||
rset.close();
|
||||
statement.close();
|
||||
|
||||
if (objId == 0)
|
||||
final int objId = CharNameTable.getInstance().getIdByName(playerName);
|
||||
if (objId != 0)
|
||||
{
|
||||
con.close();
|
||||
return;
|
||||
// Delete player's shortcuts.
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, objId);
|
||||
ps.execute();
|
||||
}
|
||||
// Move all items to the inventory.
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?"))
|
||||
{
|
||||
ps.setInt(1, objId);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
|
||||
// connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
// connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not repair char:", e);
|
||||
_log.log(Level.WARNING, "Could not repair char:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
@@ -174,7 +174,8 @@ public class AdminShowQuests implements IAdminCommandHandler
|
||||
|
||||
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
// TODO(Zoey76): Refactor this into smaller methods and separate database access logic from HTML creation.
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection())
|
||||
{
|
||||
ResultSet rs;
|
||||
PreparedStatement req;
|
||||
|
@@ -26,7 +26,7 @@ import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
@@ -510,16 +510,16 @@ public class AdminTeleport implements IAdminCommandHandler
|
||||
final int x = activeChar.getX();
|
||||
final int y = activeChar.getY();
|
||||
final int z = activeChar.getZ();
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?"))
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
|
||||
statement.setInt(1, x);
|
||||
statement.setInt(2, y);
|
||||
statement.setInt(3, z);
|
||||
statement.setString(4, name);
|
||||
statement.execute();
|
||||
int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
ps.setInt(1, x);
|
||||
ps.setInt(2, y);
|
||||
ps.setInt(3, z);
|
||||
ps.setString(4, name);
|
||||
ps.execute();
|
||||
int count = ps.getUpdateCount();
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
activeChar.sendMessage("Character not found or position unaltered.");
|
||||
|
@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
|
||||
import com.l2jserver.gameserver.handler.IParseBoardHandler;
|
||||
@@ -63,7 +63,7 @@ public class FavoriteBoard implements IParseBoardHandler
|
||||
// Load Favorite links
|
||||
final String list = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/CommunityBoard/favorite_list.html");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(SELECT_FAVORITES))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
@@ -100,7 +100,7 @@ public class FavoriteBoard implements IParseBoardHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(ADD_FAVORITE))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
@@ -125,7 +125,7 @@ public class FavoriteBoard implements IParseBoardHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(DELETE_FAVORITE))
|
||||
{
|
||||
ps.setInt(1, activeChar.getObjectId());
|
||||
|
@@ -23,7 +23,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jserver.gameserver.data.xml.impl.BuyListData;
|
||||
@@ -178,7 +178,7 @@ public final class HomeBoard implements IParseBoardHandler
|
||||
private static int getFavoriteCount(L2PcInstance player)
|
||||
{
|
||||
int count = 0;
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(COUNT_FAVORITES))
|
||||
{
|
||||
ps.setInt(1, player.getObjectId());
|
||||
|
@@ -24,7 +24,7 @@ import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.handler.IUserCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
@@ -64,57 +64,53 @@ public class ClanWarsList implements IUserCommandHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
String query;
|
||||
// Attack List
|
||||
if (id == 88)
|
||||
{
|
||||
String query;
|
||||
// Attack List
|
||||
if (id == 88)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CLANS_YOU_VE_DECLARED_WAR_ON);
|
||||
query = ATTACK_LIST;
|
||||
}
|
||||
// Under Attack List
|
||||
else if (id == 89)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU);
|
||||
query = UNDER_ATTACK_LIST;
|
||||
}
|
||||
// War List
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CLAN_WAR_LIST);
|
||||
query = WAR_LIST;
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.CLANS_YOU_VE_DECLARED_WAR_ON);
|
||||
query = ATTACK_LIST;
|
||||
}
|
||||
// Under Attack List
|
||||
else if (id == 89)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CLANS_THAT_HAVE_DECLARED_WAR_ON_YOU);
|
||||
query = UNDER_ATTACK_LIST;
|
||||
}
|
||||
// War List
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.CLAN_WAR_LIST);
|
||||
query = WAR_LIST;
|
||||
}
|
||||
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement(query))
|
||||
{
|
||||
ps.setInt(1, clan.getId());
|
||||
ps.setInt(2, clan.getId());
|
||||
|
||||
try (PreparedStatement ps = con.prepareStatement(query))
|
||||
SystemMessage sm;
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
{
|
||||
ps.setInt(1, clan.getId());
|
||||
ps.setInt(2, clan.getId());
|
||||
|
||||
SystemMessage sm;
|
||||
try (ResultSet rs = ps.executeQuery())
|
||||
while (rs.next())
|
||||
{
|
||||
String clanName;
|
||||
int ally_id;
|
||||
while (rs.next())
|
||||
String clanName = rs.getString("clan_name");
|
||||
int allyId = rs.getInt("ally_id");
|
||||
if (allyId > 0)
|
||||
{
|
||||
clanName = rs.getString("clan_name");
|
||||
ally_id = rs.getInt("ally_id");
|
||||
if (ally_id > 0)
|
||||
{
|
||||
// Target With Ally
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
|
||||
sm.addString(clanName);
|
||||
sm.addString(rs.getString("ally_name"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Target Without Ally
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLIANCE_EXISTS);
|
||||
sm.addString(clanName);
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
// Target With Ally
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2_ALLIANCE);
|
||||
sm.addString(clanName);
|
||||
sm.addString(rs.getString("ally_name"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Target Without Ally
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_NO_ALLIANCE_EXISTS);
|
||||
sm.addString(clanName);
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.EMPTY3);
|
||||
|
@@ -25,7 +25,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
|
||||
import com.l2jserver.gameserver.GameTimeController;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
@@ -209,30 +209,29 @@ public class Wedding implements IVoicedCommandHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if target has player on friendlist
|
||||
boolean FoundOnFriendList = false;
|
||||
int objectId;
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
// Check if target has player on friend list
|
||||
boolean foundOnFriendList = false;
|
||||
try (Connection con = ConnectionFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?"))
|
||||
{
|
||||
final PreparedStatement statement = con.prepareStatement("SELECT friendId FROM character_friends WHERE charId=?");
|
||||
statement.setInt(1, ptarget.getObjectId());
|
||||
final ResultSet rset = statement.executeQuery();
|
||||
while (rset.next())
|
||||
try (ResultSet rset = statement.executeQuery())
|
||||
{
|
||||
objectId = rset.getInt("friendId");
|
||||
if (objectId == activeChar.getObjectId())
|
||||
while (rset.next())
|
||||
{
|
||||
FoundOnFriendList = true;
|
||||
if (rset.getInt("friendId") == activeChar.getObjectId())
|
||||
{
|
||||
foundOnFriendList = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("could not read friend data:" + e);
|
||||
}
|
||||
|
||||
if (!FoundOnFriendList)
|
||||
if (!foundOnFriendList)
|
||||
{
|
||||
activeChar.sendMessage("The player you want to ask is not on your friends list, you must first be on each others friends list before you choose to engage.");
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user