diff --git a/backend/fabric/src/main/java/io/github/_4drian3d/signedvelocity/fabric/model/QueuedDataPacket.java b/backend/fabric/src/main/java/io/github/_4drian3d/signedvelocity/fabric/model/QueuedDataPacket.java index 95b4410..4a24f50 100644 --- a/backend/fabric/src/main/java/io/github/_4drian3d/signedvelocity/fabric/model/QueuedDataPacket.java +++ b/backend/fabric/src/main/java/io/github/_4drian3d/signedvelocity/fabric/model/QueuedDataPacket.java @@ -1,5 +1,7 @@ package io.github._4drian3d.signedvelocity.fabric.model; +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; import io.github._4drian3d.signedvelocity.fabric.SignedVelocity; import io.netty.buffer.ByteBuf; import net.minecraft.network.FriendlyByteBuf; @@ -20,12 +22,12 @@ public record QueuedDataPacket( public static final StreamCodec PACKET_CODEC = CustomPacketPayload.codec(QueuedDataPacket::write, QueuedDataPacket::generate); public static QueuedDataPacket generate(final ByteBuf buf) { - final FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(buf); - final UUID playerId = friendlyByteBuf.readUUID(); - final String source = friendlyByteBuf.readUtf(); - final String result = friendlyByteBuf.readUtf(); + final ByteArrayDataInput input = ByteStreams.newDataInput(convertFromBuf(buf)); + final UUID playerId = UUID.fromString(input.readUTF()); + final String source = input.readUTF(); + final String result = input.readUTF(); final String modifiedMessage = result.equals("MODIFY") - ? friendlyByteBuf.readUtf() + ? input.readUTF() : null; return new QueuedDataPacket(playerId, source, result, modifiedMessage); } @@ -43,4 +45,10 @@ public static void write(final QueuedDataPacket packet, final ByteBuf buf) { public @NotNull Type type() { return PACKET_ID; } + + private static byte[] convertFromBuf(final ByteBuf buf) { + final byte[] bytes = new byte[buf.readableBytes()]; + buf.readBytes(bytes); + return bytes; + } }