mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 07:54:47 +01:00
175 lines
7.7 KiB
Diff
175 lines
7.7 KiB
Diff
--- a/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -35,6 +35,10 @@
|
|
import org.apache.commons.lang3.mutable.MutableBoolean;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.world.ChunkUnloadEvent;
|
|
+// CraftBukkit end
|
|
|
|
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
|
|
|
@@ -181,9 +185,12 @@
|
|
|
|
return completablefuture1.thenApply((list1) -> {
|
|
List<IChunkAccess> list2 = Lists.newArrayList();
|
|
- final int l1 = 0;
|
|
+ // CraftBukkit start - decompile error
|
|
+ int cnt = 0;
|
|
|
|
- for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++l1) {
|
|
+ for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++cnt) {
|
|
+ final int l1 = cnt;
|
|
+ // CraftBukkit end
|
|
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
|
|
Optional<IChunkAccess> optional = either.left();
|
|
|
|
@@ -279,7 +286,7 @@
|
|
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.x.getName());
|
|
} else {
|
|
this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
|
|
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null);
|
|
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
|
|
|
|
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
|
|
this.saveChunk(ichunkaccess);
|
|
@@ -290,7 +297,6 @@
|
|
}
|
|
|
|
}
|
|
-
|
|
protected void unloadChunks(BooleanSupplier booleansupplier) {
|
|
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
|
|
|
@@ -330,9 +336,19 @@
|
|
if (this.loadedChunks.remove(i) && ichunkaccess instanceof Chunk) {
|
|
Chunk chunk = (Chunk) ichunkaccess;
|
|
|
|
+ // CraftBukkit start
|
|
+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk, chunk.isNeedsSaving());
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
+ this.saveChunk(ichunkaccess, event.isSaveChunk());
|
|
+ // CraftBukkit end
|
|
+
|
|
chunk.setLoaded(false);
|
|
this.world.unloadChunk(chunk);
|
|
+ // CraftBukkit start
|
|
+ } else {
|
|
+ this.saveChunk(ichunkaccess);
|
|
}
|
|
+ // CraftBukkit end
|
|
|
|
this.lightEngine.a(ichunkaccess.getPos());
|
|
this.lightEngine.queueUpdate();
|
|
@@ -416,7 +432,7 @@
|
|
return CompletableFuture.completedFuture(Either.right(playerchunk_failure));
|
|
});
|
|
}, (runnable) -> {
|
|
- this.mailboxWorldGen.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
+ this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
});
|
|
}
|
|
}
|
|
@@ -498,7 +514,7 @@
|
|
long i = playerchunk.h().pair();
|
|
|
|
playerchunk.getClass();
|
|
- mailbox.a((Object) ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel));
|
|
+ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); // CraftBukkit - decompile error
|
|
});
|
|
}
|
|
|
|
@@ -515,7 +531,7 @@
|
|
return Either.left(chunk);
|
|
});
|
|
}, (runnable) -> {
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
});
|
|
|
|
completablefuture1.thenAcceptAsync((either) -> {
|
|
@@ -529,7 +545,7 @@
|
|
return Either.left(chunk);
|
|
});
|
|
}, (runnable) -> {
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
});
|
|
return completablefuture1;
|
|
}
|
|
@@ -543,7 +559,7 @@
|
|
return chunk;
|
|
});
|
|
}, (runnable) -> {
|
|
- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable));
|
|
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
|
|
});
|
|
}
|
|
|
|
@@ -552,8 +568,14 @@
|
|
}
|
|
|
|
public boolean saveChunk(IChunkAccess ichunkaccess) {
|
|
+ // CraftBukkit start
|
|
+ return this.saveChunk(ichunkaccess, ichunkaccess.isNeedsSaving());
|
|
+ }
|
|
+
|
|
+ public boolean saveChunk(IChunkAccess ichunkaccess, boolean save) {
|
|
+ // CraftBukkit end
|
|
this.n.a(ichunkaccess.getPos());
|
|
- if (!ichunkaccess.isNeedsSaving()) {
|
|
+ if (!save) { // CraftBukkit
|
|
return false;
|
|
} else {
|
|
try {
|
|
@@ -607,9 +629,10 @@
|
|
ChunkCoordIntPair chunkcoordintpair = playerchunk.h();
|
|
Packet<?>[] apacket = new Packet[2];
|
|
|
|
+ int finall = l; // CraftBukkit - decompile error
|
|
this.a(chunkcoordintpair, false).forEach((entityplayer) -> {
|
|
int i1 = b(chunkcoordintpair, entityplayer, true);
|
|
- boolean flag = i1 <= l;
|
|
+ boolean flag = i1 <= finall; // CraftBukkit - decompile error
|
|
boolean flag1 = i1 <= this.viewDistance;
|
|
|
|
this.sendChunk(entityplayer, chunkcoordintpair, apacket, flag, flag1);
|
|
@@ -664,7 +687,7 @@
|
|
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
|
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
|
|
|
|
- return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound);
|
|
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
|
}
|
|
|
|
boolean d(ChunkCoordIntPair chunkcoordintpair) {
|
|
@@ -984,7 +1007,7 @@
|
|
public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
|
|
|
|
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
|
- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast);
|
|
+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit
|
|
this.tracker = entity;
|
|
this.trackingDistance = i;
|
|
this.e = SectionPosition.a(entity);
|
|
@@ -1053,6 +1076,17 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start - respect vanish API
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
|
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
|
+ flag1 = false;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
|
+ // CraftBukkit end
|
|
+
|
|
if (flag1 && this.trackedPlayers.add(entityplayer)) {
|
|
this.trackerEntry.b(entityplayer);
|
|
}
|