mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-04 18:51:16 +02:00
Merge branch 'master' of https://github.com/Minestom/Minestom
This commit is contained in:
commit
c1c84217c2
|
@ -127,17 +127,18 @@ public class ChunkBatch implements InstanceBatch {
|
|||
chunkPopulator.populateChunk(this, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh chunk for viewers
|
||||
this.chunk.sendChunkUpdate();
|
||||
|
||||
this.instance.refreshLastBlockChangeTime();
|
||||
|
||||
// Safe callback
|
||||
instance.scheduleNextTick(inst -> {
|
||||
OptionalCallback.execute(callback, chunk);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Refresh chunk for viewers
|
||||
this.chunk.sendChunkUpdate();
|
||||
|
||||
this.instance.refreshLastBlockChangeTime();
|
||||
|
||||
// Safe callback
|
||||
instance.scheduleNextTick(inst -> {
|
||||
OptionalCallback.execute(callback, chunk);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -199,9 +200,9 @@ public class ChunkBatch implements InstanceBatch {
|
|||
// Refresh chunk for viewers
|
||||
chunk.sendChunkUpdate();
|
||||
|
||||
if (callback != null) {
|
||||
this.instance.refreshLastBlockChangeTime();
|
||||
this.instance.refreshLastBlockChangeTime();
|
||||
|
||||
if (callback != null) {
|
||||
if (safeCallback) {
|
||||
this.instance.scheduleNextTick(inst -> callback.accept(chunk));
|
||||
} else {
|
||||
|
|
|
@ -124,7 +124,7 @@ public class NettyPlayerConnection extends PlayerConnection {
|
|||
} else {
|
||||
// Try to retrieve the cached buffer
|
||||
TemporaryCache<ByteBuf> temporaryCache = cacheablePacket.getCache();
|
||||
ByteBuf buffer = temporaryCache.retrieve(identifier);
|
||||
ByteBuf buffer = temporaryCache.retrieve(identifier, cacheablePacket.getLastUpdateTime());
|
||||
if (buffer == null) {
|
||||
// Buffer not found, create and cache it
|
||||
final long time = System.currentTimeMillis();
|
||||
|
|
|
@ -60,8 +60,13 @@ public class TemporaryCache<T> {
|
|||
* @return the retrieved object or null if not found
|
||||
*/
|
||||
@Nullable
|
||||
public T retrieve(@NotNull UUID identifier) {
|
||||
return cache.get(identifier);
|
||||
public synchronized T retrieve(@NotNull UUID identifier, long lastUpdate) {
|
||||
if (!cacheTime.containsKey(identifier)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final long cachedTime = cacheTime.get(identifier);
|
||||
return lastUpdate <= cachedTime ? cache.get(identifier) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user