From 2e02dfd4d8c9d865c9e0b1b5941060486f54607f Mon Sep 17 00:00:00 2001 From: themode Date: Sat, 5 Feb 2022 08:21:19 +0100 Subject: [PATCH] Fix synchronization issue with viewable packets --- src/main/java/net/minestom/server/utils/PacketUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minestom/server/utils/PacketUtils.java b/src/main/java/net/minestom/server/utils/PacketUtils.java index c69493c80..dbe19f717 100644 --- a/src/main/java/net/minestom/server/utils/PacketUtils.java +++ b/src/main/java/net/minestom/server/utils/PacketUtils.java @@ -284,7 +284,7 @@ public final class PacketUtils { PooledBuffers.registerBuffer(this, buffer); } - private void append(Viewable viewable, ServerPacket serverPacket, Player player) { + private synchronized void append(Viewable viewable, ServerPacket serverPacket, Player player) { final ByteBuffer framedPacket = createFramedPacket(serverPacket); final int packetSize = framedPacket.limit(); if (packetSize >= buffer.capacity()) { @@ -307,7 +307,7 @@ public final class PacketUtils { } } - private void process(Viewable viewable) { + private synchronized void process(Viewable viewable) { if (buffer.writerOffset() == 0) return; ByteBuffer copy = ByteBuffer.allocateDirect(buffer.writerOffset()); copy.put(buffer.asByteBuffer(0, copy.capacity()));