From 5610e74ef7c918c41c174edf2cf715e2e376bc8e Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 12 Jun 2018 03:34:23 +0000 Subject: [PATCH] Disconnection task improvement. Contributed by Sahar. --- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- .../gameserver/network/Disconnection.java | 19 +++++++++++++++++-- 8 files changed, 136 insertions(+), 16 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/Disconnection.java index b2440b70ab..fcbf8660fa 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/Disconnection.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/Disconnection.java index f11b3da8bf..741fa17f4a 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/Disconnection.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/Disconnection.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.network; +import java.util.concurrent.ScheduledFuture; import java.util.logging.Logger; import com.l2jmobius.commons.concurrent.ThreadPool; @@ -33,6 +34,8 @@ public final class Disconnection { private static final Logger LOGGER = Logger.getLogger(Disconnection.class.getName()); + private ScheduledFuture _disconnectionTask; + public static L2GameClient getClient(L2GameClient client, L2PcInstance activeChar) { if (client != null) @@ -167,12 +170,24 @@ public final class Disconnection public void defaultSequence(boolean toLoginScreen) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(toLoginScreen); } public void defaultSequence(IClientOutgoingPacket packet) { + if (_disconnectionTask != null) + { + _disconnectionTask.cancel(false); + _disconnectionTask = null; + } + defaultSequence(); close(packet); } @@ -185,9 +200,9 @@ public final class Disconnection public void onDisconnection() { - if (_activeChar != null) + if ((_activeChar != null) && (_disconnectionTask == null)) { - ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); + _disconnectionTask = ThreadPool.schedule(() -> defaultSequence(), _activeChar.canLogout() ? 0 : AttackStanceTaskManager.COMBAT_TIME); } } } \ No newline at end of file