From 187784662932e50bbe900280d894d7fa883254b5 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 20 Oct 2017 15:11:22 +0000 Subject: [PATCH] Do not restore offline traders that have been kicked from the game. --- .../admincommandhandlers/AdminKick.java | 7 ++++++- .../admincommandhandlers/AdminMenu.java | 5 +++++ .../data/sql/impl/OfflineTradersTable.java | 20 +++++++++++++++++++ .../admincommandhandlers/AdminKick.java | 7 ++++++- .../admincommandhandlers/AdminMenu.java | 5 +++++ .../data/sql/impl/OfflineTradersTable.java | 20 +++++++++++++++++++ .../admincommandhandlers/AdminKick.java | 7 ++++++- .../admincommandhandlers/AdminMenu.java | 5 +++++ .../data/sql/impl/OfflineTradersTable.java | 20 +++++++++++++++++++ .../admincommandhandlers/AdminKick.java | 7 ++++++- .../admincommandhandlers/AdminMenu.java | 5 +++++ .../data/sql/impl/OfflineTradersTable.java | 20 +++++++++++++++++++ .../admincommandhandlers/AdminKick.java | 7 ++++++- .../admincommandhandlers/AdminMenu.java | 5 +++++ .../data/sql/impl/OfflineTradersTable.java | 20 +++++++++++++++++++ 15 files changed, 155 insertions(+), 5 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java index 44935cd826..7e2e74e819 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; @@ -43,6 +44,10 @@ public class AdminKick implements IAdminCommandHandler final L2PcInstance plyr = L2World.getInstance().getPlayer(player); if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); activeChar.sendMessage("You kicked " + plyr.getName() + " from the game."); } @@ -59,7 +64,7 @@ public class AdminKick implements IAdminCommandHandler player.logout(); } } - activeChar.sendMessage("Kicked " + counter + " players"); + activeChar.sendMessage("Kicked " + counter + " players."); } return true; } diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java index c2347a232e..c7d395af30 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.l2jmobius.Config; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.data.xml.impl.AdminData; import com.l2jmobius.gameserver.handler.AdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; @@ -169,6 +170,10 @@ public class AdminMenu implements IAdminCommandHandler String text; if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); text = "You kicked " + plyr.getName() + " from the game."; } diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java index 148355a8f7..0b96b92d67 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java @@ -322,6 +322,26 @@ public class OfflineTradersTable } } + public static synchronized void removeTrader(int traderObjId) + { + try (Connection con = DatabaseFactory.getInstance().getConnection(); + PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); + PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER)) + { + stm1.setInt(1, traderObjId); + stm1.execute(); + stm1.close(); + + stm2.setInt(1, traderObjId); + stm2.execute(); + stm2.close(); + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, "OfflineTradersTable[onTransaction()]: Error while removing offline trader: " + traderObjId + " " + e, e); + } + } + public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall) { try (Connection con = DatabaseFactory.getInstance().getConnection(); diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java index 44935cd826..7e2e74e819 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; @@ -43,6 +44,10 @@ public class AdminKick implements IAdminCommandHandler final L2PcInstance plyr = L2World.getInstance().getPlayer(player); if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); activeChar.sendMessage("You kicked " + plyr.getName() + " from the game."); } @@ -59,7 +64,7 @@ public class AdminKick implements IAdminCommandHandler player.logout(); } } - activeChar.sendMessage("Kicked " + counter + " players"); + activeChar.sendMessage("Kicked " + counter + " players."); } return true; } diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java index c2347a232e..c7d395af30 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.l2jmobius.Config; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.data.xml.impl.AdminData; import com.l2jmobius.gameserver.handler.AdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; @@ -169,6 +170,10 @@ public class AdminMenu implements IAdminCommandHandler String text; if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); text = "You kicked " + plyr.getName() + " from the game."; } diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java index 148355a8f7..0b96b92d67 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java @@ -322,6 +322,26 @@ public class OfflineTradersTable } } + public static synchronized void removeTrader(int traderObjId) + { + try (Connection con = DatabaseFactory.getInstance().getConnection(); + PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); + PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER)) + { + stm1.setInt(1, traderObjId); + stm1.execute(); + stm1.close(); + + stm2.setInt(1, traderObjId); + stm2.execute(); + stm2.close(); + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, "OfflineTradersTable[onTransaction()]: Error while removing offline trader: " + traderObjId + " " + e, e); + } + } + public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall) { try (Connection con = DatabaseFactory.getInstance().getConnection(); diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java index 44935cd826..7e2e74e819 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; @@ -43,6 +44,10 @@ public class AdminKick implements IAdminCommandHandler final L2PcInstance plyr = L2World.getInstance().getPlayer(player); if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); activeChar.sendMessage("You kicked " + plyr.getName() + " from the game."); } @@ -59,7 +64,7 @@ public class AdminKick implements IAdminCommandHandler player.logout(); } } - activeChar.sendMessage("Kicked " + counter + " players"); + activeChar.sendMessage("Kicked " + counter + " players."); } return true; } diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java index c2347a232e..c7d395af30 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.l2jmobius.Config; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.data.xml.impl.AdminData; import com.l2jmobius.gameserver.handler.AdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; @@ -169,6 +170,10 @@ public class AdminMenu implements IAdminCommandHandler String text; if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); text = "You kicked " + plyr.getName() + " from the game."; } diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java index 148355a8f7..0b96b92d67 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java @@ -322,6 +322,26 @@ public class OfflineTradersTable } } + public static synchronized void removeTrader(int traderObjId) + { + try (Connection con = DatabaseFactory.getInstance().getConnection(); + PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); + PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER)) + { + stm1.setInt(1, traderObjId); + stm1.execute(); + stm1.close(); + + stm2.setInt(1, traderObjId); + stm2.execute(); + stm2.close(); + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, "OfflineTradersTable[onTransaction()]: Error while removing offline trader: " + traderObjId + " " + e, e); + } + } + public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall) { try (Connection con = DatabaseFactory.getInstance().getConnection(); diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java index 0aa1aa0002..5ef0d3cf0a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; @@ -43,6 +44,10 @@ public class AdminKick implements IAdminCommandHandler final L2PcInstance plyr = L2World.getInstance().getPlayer(player); if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); activeChar.sendMessage("You kicked " + plyr.getName() + " from the game."); } @@ -59,7 +64,7 @@ public class AdminKick implements IAdminCommandHandler player.logout(); } } - activeChar.sendMessage("Kicked " + counter + " players"); + activeChar.sendMessage("Kicked " + counter + " players."); } return true; } diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java index 67d26e6ebb..b84b6b380b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.l2jmobius.Config; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.data.xml.impl.AdminData; import com.l2jmobius.gameserver.handler.AdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; @@ -171,6 +172,10 @@ public class AdminMenu implements IAdminCommandHandler String text; if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); text = "You kicked " + plyr.getName() + " from the game."; } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java index 0340fa2701..03ffb776af 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java @@ -284,6 +284,26 @@ public class OfflineTradersTable } } + public static synchronized void removeTrader(int traderObjId) + { + try (Connection con = DatabaseFactory.getInstance().getConnection(); + PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); + PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER)) + { + stm1.setInt(1, traderObjId); + stm1.execute(); + stm1.close(); + + stm2.setInt(1, traderObjId); + stm2.execute(); + stm2.close(); + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, "OfflineTradersTable[onTransaction()]: Error while removing offline trader: " + traderObjId + " " + e, e); + } + } + public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall) { try (Connection con = DatabaseFactory.getInstance().getConnection(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java index 44935cd826..7e2e74e819 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminKick.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; @@ -43,6 +44,10 @@ public class AdminKick implements IAdminCommandHandler final L2PcInstance plyr = L2World.getInstance().getPlayer(player); if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); activeChar.sendMessage("You kicked " + plyr.getName() + " from the game."); } @@ -59,7 +64,7 @@ public class AdminKick implements IAdminCommandHandler player.logout(); } } - activeChar.sendMessage("Kicked " + counter + " players"); + activeChar.sendMessage("Kicked " + counter + " players."); } return true; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java index c2347a232e..c7d395af30 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminMenu.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.l2jmobius.Config; +import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable; import com.l2jmobius.gameserver.data.xml.impl.AdminData; import com.l2jmobius.gameserver.handler.AdminCommandHandler; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; @@ -169,6 +170,10 @@ public class AdminMenu implements IAdminCommandHandler String text; if (plyr != null) { + if (plyr.getOfflineStartTime() > 0) + { + OfflineTradersTable.removeTrader(plyr.getObjectId()); + } plyr.logout(); text = "You kicked " + plyr.getName() + " from the game."; } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java index 148355a8f7..0b96b92d67 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/data/sql/impl/OfflineTradersTable.java @@ -322,6 +322,26 @@ public class OfflineTradersTable } } + public static synchronized void removeTrader(int traderObjId) + { + try (Connection con = DatabaseFactory.getInstance().getConnection(); + PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER); + PreparedStatement stm2 = con.prepareStatement(CLEAR_OFFLINE_TABLE_PLAYER)) + { + stm1.setInt(1, traderObjId); + stm1.execute(); + stm1.close(); + + stm2.setInt(1, traderObjId); + stm2.execute(); + stm2.close(); + } + catch (Exception e) + { + LOGGER.log(Level.WARNING, "OfflineTradersTable[onTransaction()]: Error while removing offline trader: " + traderObjId + " " + e, e); + } + } + public static synchronized void onTransaction(L2PcInstance trader, boolean finished, boolean firstCall) { try (Connection con = DatabaseFactory.getInstance().getConnection();