3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.

Dieser Commit ist enthalten in:
blablubbabc 2019-06-12 20:05:29 +02:00 committet von md_5
Ursprung d445af3b14
Commit e8c0836216

Datei anzeigen

@ -9,12 +9,13 @@
this.dirtyBlocks = new short[64]; this.dirtyBlocks = new short[64];
this.location = chunkcoordintpair; this.location = chunkcoordintpair;
this.lightEngine = lightengine; this.lightEngine = lightengine;
@@ -55,6 +55,14 @@ @@ -55,6 +55,15 @@
this.a(i); this.a(i);
} }
+ // CraftBukkit start + // CraftBukkit start
+ public Chunk getFullChunk() { + public Chunk getFullChunk() {
+ if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks
+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getStatusFutureUnchecked(ChunkStatus.FULL); + CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getStatusFutureUnchecked(ChunkStatus.FULL);
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either<IChunkAccess, PlayerChunk.Failure>) statusFuture.getNow(null); + Either<IChunkAccess, PlayerChunk.Failure> either = (Either<IChunkAccess, PlayerChunk.Failure>) statusFuture.getNow(null);
+ return either == null ? null : (Chunk) either.left().orElse(null); + return either == null ? null : (Chunk) either.left().orElse(null);
@ -24,7 +25,7 @@
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) { public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c());
@@ -72,9 +80,9 @@ @@ -72,9 +81,9 @@
@Nullable @Nullable
public Chunk getChunk() { public Chunk getChunk() {
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a(); CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a();
@ -36,7 +37,7 @@
} }
public CompletableFuture<IChunkAccess> getChunkSave() { public CompletableFuture<IChunkAccess> getChunkSave() {
@@ -197,7 +205,7 @@ @@ -197,7 +206,7 @@
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(i); CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(i);
if (completablefuture != null) { if (completablefuture != null) {
@ -45,7 +46,7 @@
if (either == null || either.left().isPresent()) { if (either == null || either.left().isPresent()) {
return completablefuture; return completablefuture;
@@ -252,6 +260,21 @@ @@ -252,6 +261,21 @@
boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET; boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET;
PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel);
PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel);
@ -67,7 +68,7 @@
CompletableFuture completablefuture; CompletableFuture completablefuture;
if (flag) { if (flag) {
@@ -283,7 +306,7 @@ @@ -283,7 +307,7 @@
if (flag2 && !flag3) { if (flag2 && !flag3) {
completablefuture = this.fullChunkFuture; completablefuture = this.fullChunkFuture;
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
@ -76,7 +77,7 @@
playerchunkmap.getClass(); playerchunkmap.getClass();
return either1.ifLeft(playerchunkmap::a); return either1.ifLeft(playerchunkmap::a);
})); }));
@@ -321,6 +344,17 @@ @@ -321,6 +345,17 @@
this.w.a(this.location, this::j, this.ticketLevel, this::d); this.w.a(this.location, this::j, this.ticketLevel, this::d);
this.oldTicketLevel = this.ticketLevel; this.oldTicketLevel = this.ticketLevel;