Class CachedPacket
java.lang.Object
net.minestom.server.network.packet.server.CachedPacket
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionCachedPacket
(@NotNull Supplier<@NotNull ServerPacket> packetSupplier) CachedPacket
(@NotNull ServerPacket packet) -
Method Summary
Modifier and TypeMethodDescription@Nullable ByteBuffer
body
(@NotNull ConnectionState state) void
boolean
isValid()
@NotNull ServerPacket
packet
(@NotNull ConnectionState state)
-
Constructor Details
-
CachedPacket
-
CachedPacket
-
-
Method Details
-
invalidate
public void invalidate() -
packet
-
body
-
isValid
public boolean isValid()
-