fix: remove length limit for WrapperPlayClientPluginMessage#1502
fix: remove length limit for WrapperPlayClientPluginMessage#1502Kowagirl wants to merge 1 commit into
Conversation
|
Don't merge, doing some investigation first. |
|
@retrooper The issue I was encountering was due to NuVotifier/NuVotifier#344, but this PR did help me diagnose it, so it might be worth merging. I also checked the NMS code and I think the server will always reject the packet if it is above the limit, I'm not sure where the docs are getting that from: ServerboundCustomPayloadPacket.java public static final StreamCodec<FriendlyByteBuf, ServerboundCustomPayloadPacket> STREAM_CODEC = CustomPacketPayload.<FriendlyByteBuf>codec(
id -> DiscardedPayload.codec(id, 32767),
java.util.Collections.emptyList() // CraftBukkit - treat all packets the same
)
.map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload);DiscardedPayload.java public static <T extends FriendlyByteBuf> StreamCodec<T, DiscardedPayload> codec(Identifier id, int maxSize) {
return CustomPacketPayload.codec((value, output) -> {
// Paper start
// Always write data
output.writeBytes(value.data);
}, buffer -> {
int i = buffer.readableBytes();
if (i >= 0 && i <= maxSize) {
final byte[] data = new byte[i];
buffer.readBytes(data);
return new DiscardedPayload(id, data);
// Paper end
} else {
throw new IllegalArgumentException("Payload may not be larger than " + maxSize + " bytes");
}
});
}Your call on if this should be merged. At the very least it would stop folks from making a PacketEvents (or plugin that uses PacketEvents) issue when they see the console error, and will give a way for devs to debug which plugin is actually producing the oversized packet. Alternatively we could include the |
Closes #1133
This packet may be larger than 32767 bytes:
https://minecraft.wiki/w/Java_Edition_protocol/Packets#Serverbound_Plugin_Message_(play)