diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java index 85c39169b..6e2190775 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java @@ -1,6 +1,7 @@ package net.minestom.server.network.packet.server.play; import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; @@ -13,7 +14,6 @@ import net.minestom.server.instance.palette.Section; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.utils.BlockPosition; -import net.minestom.server.utils.BufUtils; import net.minestom.server.utils.Utils; import net.minestom.server.utils.binary.BinaryReader; import net.minestom.server.utils.binary.BinaryWriter; @@ -82,7 +82,7 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket { writer.writeBoolean(fullChunk); int mask = 0; - ByteBuf blocks = BufUtils.getBuffer(MAX_BUFFER_SIZE); + ByteBuf blocks = Unpooled.buffer(MAX_BUFFER_SIZE); for (byte i = 0; i < CHUNK_SECTION_COUNT; i++) { if (fullChunk || (sections.length == CHUNK_SECTION_COUNT && sections[i] != 0)) { final Section section = paletteStorage.getSections()[i]; diff --git a/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java b/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java index 669283034..ec01e998a 100644 --- a/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java +++ b/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java @@ -62,7 +62,7 @@ public class NettyPlayerConnection extends PlayerConnection { private PlayerSkin bungeeSkin; private final Object tickBufferLock = new Object(); - private volatile ByteBuf tickBuffer = BufUtils.getBuffer(true); + private volatile ByteBuf tickBuffer = BufUtils.direct(); public NettyPlayerConnection(@NotNull SocketChannel channel) { super(); diff --git a/src/main/java/net/minestom/server/utils/BufUtils.java b/src/main/java/net/minestom/server/utils/BufUtils.java index dcf25c6a2..7add90968 100644 --- a/src/main/java/net/minestom/server/utils/BufUtils.java +++ b/src/main/java/net/minestom/server/utils/BufUtils.java @@ -7,28 +7,11 @@ public class BufUtils { private static final PooledByteBufAllocator alloc = PooledByteBufAllocator.DEFAULT; - public static ByteBuf getBuffer() { - return alloc.heapBuffer(); - } - - public static ByteBuf getBuffer(boolean io) { - return io ? alloc.ioBuffer() : alloc.heapBuffer(); + public static ByteBuf direct() { + return alloc.ioBuffer(); } public static ByteBuf getBuffer(int initialCapacity) { return alloc.heapBuffer(initialCapacity); } - - public static ByteBuf getBuffer(boolean io, int initialCapacity) { - return io ? alloc.ioBuffer(initialCapacity) : alloc.heapBuffer(initialCapacity); - } - - public static ByteBuf getBuffer(int initialCapacity, int maxCapacity) { - return alloc.heapBuffer(initialCapacity, maxCapacity); - } - - public static ByteBuf getBuffer(boolean io, int initialCapacity, int maxCapacity) { - return io ? alloc.ioBuffer(initialCapacity, maxCapacity) : alloc.heapBuffer(initialCapacity, maxCapacity); - } - } diff --git a/src/main/java/net/minestom/server/utils/PacketUtils.java b/src/main/java/net/minestom/server/utils/PacketUtils.java index 8ff1c8dc6..4d7216581 100644 --- a/src/main/java/net/minestom/server/utils/PacketUtils.java +++ b/src/main/java/net/minestom/server/utils/PacketUtils.java @@ -21,7 +21,6 @@ import net.minestom.server.utils.callback.validator.PlayerValidator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.time.Duration; import java.util.Collection; import java.util.zip.DataFormatException; @@ -287,7 +286,7 @@ public final class PacketUtils { */ @NotNull public static ByteBuf createFramedPacket(@NotNull ServerPacket serverPacket, boolean directBuffer) { - ByteBuf packetBuf = directBuffer ? BufUtils.getBuffer(true) : Unpooled.buffer(); + ByteBuf packetBuf = directBuffer ? BufUtils.direct() : Unpooled.buffer(); writeFramedPacket(packetBuf, serverPacket); return packetBuf; }