diff --git a/src/main/java/net/minestom/server/network/packet/server/CachedPacket.java b/src/main/java/net/minestom/server/network/packet/server/CachedPacket.java index 750340b33..0714a0509 100644 --- a/src/main/java/net/minestom/server/network/packet/server/CachedPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/CachedPacket.java @@ -43,12 +43,12 @@ public final class CachedPacket implements SendablePacket { } public void invalidate() { - PACKET.setOpaque(this, null); + PACKET.setRelease(this, null); } public @NotNull ServerPacket packet() { @SuppressWarnings("unchecked") - SoftReference ref = (SoftReference) PACKET.getOpaque(this); + SoftReference ref = (SoftReference) PACKET.getAcquire(this); FramedPacket cache; if (ref != null && (cache = ref.get()) != null) return cache.packet(); // Avoid potential packet allocation @@ -64,11 +64,11 @@ public final class CachedPacket implements SendablePacket { if (!PacketUtils.CACHED_PACKET) return null; @SuppressWarnings("unchecked") - SoftReference ref = (SoftReference) PACKET.getOpaque(this); + SoftReference ref = (SoftReference) PACKET.getAcquire(this); FramedPacket cache; if (ref == null || (cache = ref.get()) == null) { cache = PacketUtils.allocateTrimmedPacket(packetSupplier.get()); - PACKET.setOpaque(this, new SoftReference<>(cache)); + PACKET.setRelease(this, new SoftReference<>(cache)); } return cache; } diff --git a/src/main/java/net/minestom/server/network/packet/server/LazyPacket.java b/src/main/java/net/minestom/server/network/packet/server/LazyPacket.java index d5b07c4ed..6a5672944 100644 --- a/src/main/java/net/minestom/server/network/packet/server/LazyPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/LazyPacket.java @@ -33,13 +33,13 @@ public final class LazyPacket implements SendablePacket { } public @NotNull ServerPacket packet() { - ServerPacket packet = (ServerPacket) PACKET.getOpaque(this); + ServerPacket packet = (ServerPacket) PACKET.getAcquire(this); if (packet == null) { synchronized (this) { - packet = this.packet; + packet = (ServerPacket) PACKET.getAcquire(this); if (packet == null) { packet = packetSupplier.get(); - PACKET.setOpaque(this, packet); + PACKET.setRelease(this, packet); } } }