mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-07 11:20:09 +01:00
Merge branch 'master' of https://github.com/Minestom/Minestom
This commit is contained in:
commit
c1c84217c2
@ -127,7 +127,6 @@ public class ChunkBatch implements InstanceBatch {
|
|||||||
chunkPopulator.populateChunk(this, chunk);
|
chunkPopulator.populateChunk(this, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Refresh chunk for viewers
|
// Refresh chunk for viewers
|
||||||
this.chunk.sendChunkUpdate();
|
this.chunk.sendChunkUpdate();
|
||||||
@ -138,6 +137,8 @@ public class ChunkBatch implements InstanceBatch {
|
|||||||
instance.scheduleNextTick(inst -> {
|
instance.scheduleNextTick(inst -> {
|
||||||
OptionalCallback.execute(callback, chunk);
|
OptionalCallback.execute(callback, chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,9 +200,9 @@ public class ChunkBatch implements InstanceBatch {
|
|||||||
// Refresh chunk for viewers
|
// Refresh chunk for viewers
|
||||||
chunk.sendChunkUpdate();
|
chunk.sendChunkUpdate();
|
||||||
|
|
||||||
if (callback != null) {
|
|
||||||
this.instance.refreshLastBlockChangeTime();
|
this.instance.refreshLastBlockChangeTime();
|
||||||
|
|
||||||
|
if (callback != null) {
|
||||||
if (safeCallback) {
|
if (safeCallback) {
|
||||||
this.instance.scheduleNextTick(inst -> callback.accept(chunk));
|
this.instance.scheduleNextTick(inst -> callback.accept(chunk));
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,7 +124,7 @@ public class NettyPlayerConnection extends PlayerConnection {
|
|||||||
} else {
|
} else {
|
||||||
// Try to retrieve the cached buffer
|
// Try to retrieve the cached buffer
|
||||||
TemporaryCache<ByteBuf> temporaryCache = cacheablePacket.getCache();
|
TemporaryCache<ByteBuf> temporaryCache = cacheablePacket.getCache();
|
||||||
ByteBuf buffer = temporaryCache.retrieve(identifier);
|
ByteBuf buffer = temporaryCache.retrieve(identifier, cacheablePacket.getLastUpdateTime());
|
||||||
if (buffer == null) {
|
if (buffer == null) {
|
||||||
// Buffer not found, create and cache it
|
// Buffer not found, create and cache it
|
||||||
final long time = System.currentTimeMillis();
|
final long time = System.currentTimeMillis();
|
||||||
|
@ -60,8 +60,13 @@ public class TemporaryCache<T> {
|
|||||||
* @return the retrieved object or null if not found
|
* @return the retrieved object or null if not found
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public T retrieve(@NotNull UUID identifier) {
|
public synchronized T retrieve(@NotNull UUID identifier, long lastUpdate) {
|
||||||
return cache.get(identifier);
|
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