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
ConstructorsConstructorDescriptionCachedPacket(@NotNull Supplier<@NotNull ServerPacket> packetSupplier) CachedPacket(@NotNull ServerPacket packet) -
Method Summary
Modifier and TypeMethodDescription@Nullable ByteBufferbody(@NotNull net.minestom.server.network.ConnectionState state) voidbooleanisValid()@NotNull ServerPacketpacket(@NotNull net.minestom.server.network.ConnectionState state)
-
Constructor Details
-
CachedPacket
-
CachedPacket
-
-
Method Details
-
invalidate
public void invalidate() -
packet
@NotNull public @NotNull ServerPacket packet(@NotNull @NotNull net.minestom.server.network.ConnectionState state) -
body
@Nullable public @Nullable ByteBuffer body(@NotNull @NotNull net.minestom.server.network.ConnectionState state) -
isValid
public boolean isValid()
-