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.");
|
||||
|
Reference in New Issue
Block a user