From 8ec7c2715376b97775e5ada9aef4915788e087e9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 5 Dec 2024 22:46:19 +0100 Subject: [PATCH] Check for client state in event loop in PlayerPacketsTickTask --- .DS_Store | Bin 0 -> 6148 bytes .../task/PlayerPacketsTickTask.java | 10 ++++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..09bd0100b2934159d79d2b46e397604b8f8ca7c0 GIT binary patch literal 6148 zcmeHK%}T>S5Z<+|O({YS3Oz1(E!f&BikA@U3mDOZN=-=7V9b^#HHT8jSzpK}@p+ut z-9U@Mqlle>-EVe&b~7Jje;8xjoritKY{r-c4UwZ#A!x32ZJA(1uI31XJe>xy3@WDi znfadahR9F)2r zTt}09Z10}SB=e(WGE)grIDwG6np;2ue(BbtN{dGhX(D5ySC=5CV3yt6b;W`yi zr*iYe;5r@b!o)cS3ynIRakVncV^%I7FI=q-cA>%@)>{Q`A}a|{+5 UaTc_zbU?ZYC_<%>V!Z literal 0 HcmV?d00001 diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/task/PlayerPacketsTickTask.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/task/PlayerPacketsTickTask.java index eb234be2..08d4b48a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/task/PlayerPacketsTickTask.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/task/PlayerPacketsTickTask.java @@ -21,6 +21,7 @@ import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21; import com.viaversion.viabackwards.protocol.v1_21_2to1_21.storage.PlayerStorage; import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; @@ -34,13 +35,14 @@ public final class PlayerPacketsTickTask implements Runnable { @Override public void run() { for (final UserConnection user : Via.getManager().getConnectionManager().getConnections()) { - if (user.getProtocolInfo().getClientState() != State.PLAY || !user.getProtocolInfo().getPipeline().contains(Protocol1_21_2To1_21.class)) { + final ProtocolInfo protocolInfo = user.getProtocolInfo(); + if (protocolInfo.getClientState() != State.PLAY || protocolInfo.getServerState() != State.PLAY || !protocolInfo.getPipeline().contains(Protocol1_21_2To1_21.class)) { continue; } final Channel channel = user.getChannel(); channel.eventLoop().submit(() -> { - if (!channel.isActive()) { + if (!channel.isActive() || protocolInfo.getClientState() != State.PLAY || protocolInfo.getServerState() != State.PLAY) { return; } try { @@ -48,13 +50,13 @@ public final class PlayerPacketsTickTask implements Runnable { final PlayerStorage playerStorage = user.get(PlayerStorage.class); playerStorage.tick(user); } - } catch (Throwable t) { + } catch (final Throwable t) { ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "Error while sending player input packet.", t); } try { final PacketWrapper clientTickEndPacket = PacketWrapper.create(ServerboundPackets1_21_2.CLIENT_TICK_END, user); clientTickEndPacket.sendToServer(Protocol1_21_2To1_21.class); - } catch (Throwable t) { + } catch (final Throwable t) { ViaBackwards.getPlatform().getLogger().log(Level.SEVERE, "Error while sending client tick end packet.", t); } });