Clean diff in PlayerChunkMap

This commit is contained in:
md_5 2019-04-26 13:01:07 +10:00
parent e2bbf62bf4
commit 8f2a45bf35

View file

@ -44,7 +44,7 @@
} }
}); });
@@ -280,13 +293,34 @@ @@ -280,13 +293,27 @@
for (int i = 0; longiterator.hasNext() && (booleansupplier.getAsBoolean() || i < 200 || this.unloadQueue.size() > 2000); longiterator.remove()) { for (int i = 0; longiterator.hasNext() && (booleansupplier.getAsBoolean() || i < 200 || this.unloadQueue.size() > 2000); longiterator.remove()) {
long j = longiterator.nextLong(); long j = longiterator.nextLong();
@ -54,14 +54,7 @@
if (playerchunk != null) { if (playerchunk != null) {
+ // CraftBukkit start + // CraftBukkit start
+ ChunkUnloadEvent event = null; + ChunkUnloadEvent event = null;
+ IChunkAccess access = null; + IChunkAccess access = playerchunk.getChunk();
+ try {
+ access = playerchunk.getChunkSave().get(5, TimeUnit.SECONDS);
+ } catch (ExecutionException ex) {
+ throw new CompletionException(ex);
+ } catch (InterruptedException | TimeoutException ex) {
+ System.err.println("Failed to save chunk " + playerchunk + " " + playerchunk.getChunkSave());
+ }
+ +
+ if (access instanceof Chunk) { + if (access instanceof Chunk) {
+ event = new ChunkUnloadEvent(((Chunk) access).bukkitChunk, access.isNeedsSaving()); + event = new ChunkUnloadEvent(((Chunk) access).bukkitChunk, access.isNeedsSaving());
@ -81,7 +74,7 @@
} }
} }
} }
@@ -294,17 +328,23 @@ @@ -294,17 +321,23 @@
gameprofilerfiller.exit(); gameprofilerfiller.exit();
} }
@ -108,7 +101,7 @@
if (this.h.remove(i) && ichunkaccess instanceof Chunk) { if (this.h.remove(i) && ichunkaccess instanceof Chunk) {
Chunk chunk = (Chunk) ichunkaccess; Chunk chunk = (Chunk) ichunkaccess;
@@ -394,7 +434,7 @@ @@ -394,7 +427,7 @@
return CompletableFuture.completedFuture(Either.right(playerchunk_failure)); return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
}); });
}, (runnable) -> { }, (runnable) -> {
@ -117,7 +110,7 @@
}); });
} }
} }
@@ -454,7 +494,10 @@ @@ -454,7 +487,10 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
@ -129,7 +122,7 @@
if (list == null) { if (list == null) {
list = Lists.newArrayList(new Entity[] { entity}); list = Lists.newArrayList(new Entity[] { entity});
} else { } else {
@@ -476,7 +519,7 @@ @@ -476,7 +512,7 @@
long i = playerchunk.h().pair(); long i = playerchunk.h().pair();
playerchunk.getClass(); playerchunk.getClass();
@ -138,7 +131,7 @@
}); });
} }
@@ -493,7 +536,7 @@ @@ -493,7 +529,7 @@
return Either.left(chunk); return Either.left(chunk);
}); });
}, (runnable) -> { }, (runnable) -> {
@ -147,7 +140,7 @@
}); });
completablefuture1.thenAcceptAsync((either) -> { completablefuture1.thenAcceptAsync((either) -> {
@@ -507,7 +550,7 @@ @@ -507,7 +543,7 @@
return Either.left(chunk); return Either.left(chunk);
}); });
}, (runnable) -> { }, (runnable) -> {
@ -156,7 +149,7 @@
}); });
return completablefuture1; return completablefuture1;
} }
@@ -517,8 +560,14 @@ @@ -517,8 +553,14 @@
} }
public void saveChunk(IChunkAccess ichunkaccess) { public void saveChunk(IChunkAccess ichunkaccess) {
@ -172,7 +165,7 @@
try { try {
this.world.checkSession(); this.world.checkSession();
} catch (ExceptionWorldConflict exceptionworldconflict) { } catch (ExceptionWorldConflict exceptionworldconflict) {
@@ -569,9 +618,10 @@ @@ -569,9 +611,10 @@
ChunkCoordIntPair chunkcoordintpair = playerchunk.h(); ChunkCoordIntPair chunkcoordintpair = playerchunk.h();
Packet<?>[] apacket = new Packet[2]; Packet<?>[] apacket = new Packet[2];
@ -184,7 +177,7 @@
boolean flag1 = i1 <= this.A; boolean flag1 = i1 <= this.A;
this.sendChunk(entityplayer, chunkcoordintpair, apacket, flag, flag1); this.sendChunk(entityplayer, chunkcoordintpair, apacket, flag, flag1);
@@ -626,7 +676,7 @@ @@ -626,7 +669,7 @@
private NBTTagCompound f(ChunkCoordIntPair chunkcoordintpair) throws IOException { private NBTTagCompound f(ChunkCoordIntPair chunkcoordintpair) throws IOException {
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
@ -193,7 +186,7 @@
} }
boolean d(ChunkCoordIntPair chunkcoordintpair) { boolean d(ChunkCoordIntPair chunkcoordintpair) {
@@ -946,7 +996,7 @@ @@ -946,7 +989,7 @@
public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet(); public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) { public EntityTracker(Entity entity, int i, int j, boolean flag) {
@ -202,7 +195,7 @@
this.tracker = entity; this.tracker = entity;
this.trackingDistance = i; this.trackingDistance = i;
this.e = SectionPosition.a(entity); this.e = SectionPosition.a(entity);
@@ -1015,6 +1065,17 @@ @@ -1015,6 +1058,17 @@
} }
} }