From 38c62c4cfdfbe88cffd4396347c4f9ac8a7cd3ab Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Thu, 13 Mar 2014 03:02:41 +0100 Subject: [PATCH] Ensure sendServerPacket() works in the channel thread as well. If we're already in the channel event thread, we won't go through the ChannelProxy code, so, check scheduledProcessing in the write method as well. --- .../protocol/injector/netty/ChannelInjector.java | 11 +++++++---- .../protocol/injector/netty/ClosedInjector.java | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java index 3cae6906..02b6139b 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java @@ -300,7 +300,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector { NetworkMarker marker = null; // This packet has not been seen by the main thread - if (event == null) { + if (event == null && scheduleProcessPackets.get()) { Class clazz = packet.getClass(); // Schedule the transmission on the main thread instead @@ -459,9 +459,12 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector { public void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered) { saveMarker(packet, marker); - scheduleProcessPackets.set(filtered); - invokeSendPacket(packet); - scheduleProcessPackets.set(true); + try { + scheduleProcessPackets.set(filtered); + invokeSendPacket(packet); + } finally { + scheduleProcessPackets.set(true); + } } /** diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ClosedInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ClosedInjector.java index 250002b2..e7287b7d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ClosedInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ClosedInjector.java @@ -4,8 +4,6 @@ import org.bukkit.entity.Player; import com.comphenix.protocol.PacketType.Protocol; import com.comphenix.protocol.events.NetworkMarker; -import com.comphenix.protocol.events.PacketEvent; - /** * Represents a closed injector.