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.
This commit is contained in:
Thibaut Gautier 2020-12-23 20:59:07 +01:00 committed by GitHub
parent bbb053aa4e
commit 2b22999b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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.
* <p>