diff --git a/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java b/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java index 7777b0f4c..8c1d1ecca 100644 --- a/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java +++ b/src/main/java/com/comphenix/protocol/injector/netty/channel/NettyChannelInjector.java @@ -289,8 +289,7 @@ public void readServerboundPacket(Object packet) { this.ensureInEventLoop(() -> { try { - // try to invoke the method, this should normally not fail - this.listenerInvoker.read(packet); + this.channel.pipeline().context(INBOUND_INTERCEPTOR_NAME).fireChannelRead(packet); } catch (Exception exception) { this.errorReporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_READ_PACKET) .messageParam(packet, this.playerName) diff --git a/src/main/java/com/comphenix/protocol/injector/netty/channel/PacketListenerInvoker.java b/src/main/java/com/comphenix/protocol/injector/netty/channel/PacketListenerInvoker.java index 126d3c39a..e8b43d5e1 100644 --- a/src/main/java/com/comphenix/protocol/injector/netty/channel/PacketListenerInvoker.java +++ b/src/main/java/com/comphenix/protocol/injector/netty/channel/PacketListenerInvoker.java @@ -14,13 +14,11 @@ import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.wrappers.WrappedChatComponent; -import io.netty.channel.ChannelHandlerContext; - /** * This class facilitates the invocation of methods on the current packet listener. - * It attempts to execute the send, read, and disconnect - * methods and, upon failure (either due to the absence of the method or the packet - * listener being of an incorrect type), it delegates the call to the network manager. + * It attempts to execute the send, and disconnect methods, upon failure + * (either due to the absence of the method or the packet listener being of an incorrect type), + * it delegates the call to the network manager. * *

Supported packet listener types include CONFIGURATION and PLAY. If the packet * listener does not match these types, or if the required method is missing, the @@ -43,7 +41,6 @@ public class PacketListenerInvoker { private static final boolean DOES_PACKET_LISTENER_DISCONNECT_USE_COMPONENT = doesPacketListenerDisconnectUseComponent(); private static final MethodAccessor NETWORK_MANAGER_SEND = getNetworkManagerSend(); - private static final MethodAccessor NETWORK_MANAGER_READ = getNetworkManagerRead(); private static final MethodAccessor NETWORK_MANAGER_DISCONNECT = getNetworkManagerDisconnect(); private static final MethodAccessor NETWORK_MANAGER_PACKET_LISTENER = getNetworkManagerPacketListener(); @@ -117,15 +114,6 @@ private static MethodAccessor getNetworkManagerSend() { return Accessors.getMethodAccessor(send); } - private static MethodAccessor getNetworkManagerRead() { - FuzzyReflection networkManager = FuzzyReflection.fromClass(MinecraftReflection.getNetworkManagerClass(), true); - - Method read = networkManager - .getMethodByParameters("read", ChannelHandlerContext.class, MinecraftReflection.getPacketClass()); - - return Accessors.getMethodAccessor(read); - } - private static MethodAccessor getNetworkManagerDisconnect() { FuzzyReflection networkManager = FuzzyReflection.fromClass(MinecraftReflection.getNetworkManagerClass()); @@ -190,7 +178,7 @@ private Object getPacketListener() { } /** - * Sends a packet using the current packet listener if available and valid; otherwise, + * Sends a packet using the current packet listener if available and valid; otherwise, * falls back to the network manager. * * @param packet The packet to be sent. @@ -204,15 +192,6 @@ public void send(Object packet) { } } - /** - * Reads a packet directly using the network manager. - * - * @param packet The packet to be read. - */ - public void read(Object packet) { - NETWORK_MANAGER_READ.invoke(this.networkManager, null, packet); - } - /** * Disconnects the player using the current packet listener if available and valid; otherwise, * falls back to the network manager.