Class CachedPacket

java.lang.Object
net.minestom.server.network.packet.server.CachedPacket
All Implemented Interfaces:
SendablePacket

@Internal public final class CachedPacket extends Object implements SendablePacket
Represents a packet that is only computed when required (either due to memory demand or invalidated data)

The cache is stored in a SoftReference and is invalidated when invalidate() is called.

Packet supplier must be thread-safe.

  • Constructor Details

    • CachedPacket

      public CachedPacket(@NotNull @NotNull Supplier<@NotNull ServerPacket> packetSupplier)
    • CachedPacket

      public CachedPacket(@NotNull @NotNull ServerPacket packet)
  • Method Details

    • invalidate

      public void invalidate()
    • packet

      @NotNull public @NotNull ServerPacket packet()
    • body

      @Nullable public @Nullable ByteBuffer body()