From 48f28485149096a4885ee1e9230482e4c1f79fc0 Mon Sep 17 00:00:00 2001 From: deirn Date: Mon, 15 Jan 2024 21:05:11 +0700 Subject: [PATCH] copy untyped payload buffer on read/write closes #13 (cherry picked from commit 3e1f7e3ed244cb4a42100523b13ba60c48704e3e) --- .../lol/bai/badpackets/impl/payload/UntypedPayload.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java b/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java index 46b0e01..02a27a9 100644 --- a/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java +++ b/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java @@ -21,7 +21,7 @@ public static FriendlyByteBuf.Reader reader(ResourceLocation cha @Override public void write(@NotNull FriendlyByteBuf buf) { - buf.writeBytes(buffer); + buf.writeBytes(buffer.copy()); } @Override @@ -29,4 +29,9 @@ public void write(@NotNull FriendlyByteBuf buf) { return channelId; } + @Override + public FriendlyByteBuf buffer() { + return new FriendlyByteBuf(buffer.copy()); + } + }