mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 16:41:35 +01:00
Packet caching cleanup
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
882720c822
commit
d3bea57ddc
@ -15,7 +15,7 @@ import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.Utils;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.cache.CacheablePacket;
|
||||
import net.minestom.server.utils.cache.TemporaryPacketCache;
|
||||
import net.minestom.server.utils.cache.TemporaryCache;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -27,7 +27,7 @@ import java.util.UUID;
|
||||
public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
|
||||
private static final BlockManager BLOCK_MANAGER = MinecraftServer.getBlockManager();
|
||||
private static final TemporaryPacketCache CACHE = new TemporaryPacketCache(10000L);
|
||||
private static final TemporaryCache<ByteBuf> CACHE = new TemporaryCache<>(10000L);
|
||||
|
||||
public boolean fullChunk;
|
||||
public Biome[] biomes;
|
||||
@ -139,7 +139,7 @@ public class ChunkDataPacket implements ServerPacket, CacheablePacket {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TemporaryPacketCache getCache() {
|
||||
public TemporaryCache<ByteBuf> getCache() {
|
||||
return CACHE;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package net.minestom.server.network.packet.server.play;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.cache.CacheablePacket;
|
||||
import net.minestom.server.utils.cache.TemporaryPacketCache;
|
||||
import net.minestom.server.utils.cache.TemporaryCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -13,7 +14,7 @@ import java.util.UUID;
|
||||
|
||||
public class UpdateLightPacket implements ServerPacket, CacheablePacket {
|
||||
|
||||
private static final TemporaryPacketCache CACHE = new TemporaryPacketCache(10000L);
|
||||
private static final TemporaryCache<ByteBuf> CACHE = new TemporaryCache<>(10000L);
|
||||
|
||||
public int chunkX;
|
||||
public int chunkZ;
|
||||
@ -71,7 +72,7 @@ public class UpdateLightPacket implements ServerPacket, CacheablePacket {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TemporaryPacketCache getCache() {
|
||||
public TemporaryCache<ByteBuf> getCache() {
|
||||
return CACHE;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.utils.cache;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -22,14 +23,14 @@ public interface CacheablePacket {
|
||||
* @return the temporary packet cache
|
||||
*/
|
||||
@NotNull
|
||||
TemporaryPacketCache getCache();
|
||||
TemporaryCache<ByteBuf> getCache();
|
||||
|
||||
/**
|
||||
* Gets the identifier of this packet.
|
||||
* <p>
|
||||
* Used to verify if this packet is already cached or not.
|
||||
*
|
||||
* @return this packet identifier, null to do not retrieve the cache
|
||||
* @return this packet identifier, null to prevent caching
|
||||
*/
|
||||
@Nullable
|
||||
UUID getIdentifier();
|
||||
|
@ -1,12 +0,0 @@
|
||||
package net.minestom.server.utils.cache;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* Convenient superclass of {@link TemporaryCache} explicitly for packet to store a {@link ByteBuf}.
|
||||
*/
|
||||
public class TemporaryPacketCache extends TemporaryCache<ByteBuf> {
|
||||
public TemporaryPacketCache(long keepTime) {
|
||||
super(keepTime);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user