Skip to content

Commit

Permalink
Don't use read/writeByteArray, as we know the whole payload is the by…
Browse files Browse the repository at this point in the history
…tearray
  • Loading branch information
modmuss50 committed Feb 17, 2024
1 parent 4b0f86e commit fb72c74
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,17 @@ public record Payload(byte[] data) implements RegistrySyncPayload {
public static PacketCodec<PacketByteBuf, Payload> CODEC = CustomPayload.codecOf(Payload::write, Payload::new);

Payload(PacketByteBuf buf) {
this(buf.readByteArray());
this(readAllBytes(buf));
}

private void write(PacketByteBuf buf) {
buf.writeByteArray(data);
buf.writeBytes(data);
}

private static byte[] readAllBytes(PacketByteBuf buf) {
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
return bytes;
}

@Override
Expand Down

0 comments on commit fb72c74

Please sign in to comment.