From 2b22999b94f54faaf4f19919537108d09c05aace Mon Sep 17 00:00:00 2001 From: Thibaut Gautier <30368557+terminalsin@users.noreply.github.com> Date: Wed, 23 Dec 2020 20:59:07 +0100 Subject: [PATCH] Fixed "protocollib_encoder" attempting to read non-nms packets (#959) Added an override to the encoder as such would process any non-wire packets as NMS packets. In the case of the use of different APIs, such as Artemis Packet API, such would cause a conflict and would spit out casting exceptions. It is quite easy to resolve by exclusively accepting Wire Packets and packets which are assignable to the packet class. This solves the issue and tada happy ending. --- .../comphenix/protocol/injector/netty/ChannelInjector.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java b/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java index 44ced03b..0a51184f 100644 --- a/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java +++ b/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java @@ -271,6 +271,11 @@ public class ChannelInjector extends ByteToMessageDecoder implements Injector { super.write(ctx, packet, promise); ChannelInjector.this.finalWrite(); } + + @Override + public boolean acceptOutboundMessage(Object msg) { + return msg instanceof WirePacket || MinecraftReflection.getPacketClass().isAssignableFrom(msg.getClass()); + } }; // Intercept recieved packets @@ -895,6 +900,8 @@ public class ChannelInjector extends ByteToMessageDecoder implements Injector { } } + + /** * Execute a specific command in the channel thread. *