Skip to content

Commit 499757c

Browse files
Fix PacketHandler#injectOutgoing with ProtocolLib installed
1 parent 3c374d7 commit 499757c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

invui/src/main/java/xyz/xenondevs/invui/internal/network/PacketListener.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ public void injectOutgoing(Packet<ClientGamePacketListener> packet) {
119119
}
120120

121121
try {
122-
channel.writeAndFlush(packet, new ForceChannelPromise(channel));
122+
// This is a workaround for "promise.channel does not match: com.comphenix.protocol.injector.netty.channel.NettyChannelProxy"
123+
// If ProtocolLib is installed, this.channel is a proxy channel that delegates to the real channel.
124+
// Using channel.newPromise(), we can obtain a promise bound to the real channel. Otherwise, netty will throw this exception.
125+
var channelForPromise = channel.newPromise().channel();
126+
127+
channel.writeAndFlush(packet, new ForceChannelPromise(channelForPromise));
123128
} catch (Exception e) {
124129
throw new RuntimeException(e);
125130
}

0 commit comments

Comments
 (0)