mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
63 lines
2.9 KiB
Diff
63 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Flo0 <flo.roma@web.de>
|
|
Date: Mon, 8 Apr 2024 16:43:16 +0200
|
|
Subject: [PATCH] API for checking sent chunks
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
|
|
index ee58c67cb2bd78159cce19ec75f13dc6168a0e7a..149cfb0587299f72fcfddf395fb71b70438986c1 100644
|
|
--- a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
|
|
+++ b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java
|
|
@@ -1048,6 +1048,11 @@ public class RegionizedPlayerChunkLoader {
|
|
|
|
// now all tickets should be removed, which is all of our external state
|
|
}
|
|
+
|
|
+ // For external checks
|
|
+ public it.unimi.dsi.fastutil.longs.LongOpenHashSet getSentChunksRaw() {
|
|
+ return this.sentChunks;
|
|
+ }
|
|
}
|
|
|
|
// TODO rebase into util patch
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 2d232a5e978baaedab4665ac389187f8d81c5484..2ec4d1e930b6cd02e105f5edb60493f060041589 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -3450,6 +3450,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
}
|
|
// Paper end
|
|
|
|
+ // Paper start - Add chunk view API
|
|
+ @Override
|
|
+ public Set<java.lang.Long> getSentChunkKeys() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
|
+ return it.unimi.dsi.fastutil.longs.LongSets.unmodifiable(
|
|
+ this.getHandle().chunkLoader.getSentChunksRaw().clone()
|
|
+ );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Set<org.bukkit.Chunk> getSentChunks() {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
|
+ final it.unimi.dsi.fastutil.longs.LongOpenHashSet rawChunkKeys = this.getHandle().chunkLoader.getSentChunksRaw();
|
|
+ final it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<org.bukkit.Chunk> chunks = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(rawChunkKeys.size());
|
|
+ final org.bukkit.World world = this.getWorld();
|
|
+
|
|
+ final it.unimi.dsi.fastutil.longs.LongIterator iter = this.getHandle().chunkLoader.getSentChunksRaw().longIterator();
|
|
+ while (iter.hasNext()) chunks.add(world.getChunkAt(iter.nextLong(), false));
|
|
+
|
|
+ return it.unimi.dsi.fastutil.objects.ObjectSets.unmodifiable(chunks);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isChunkSent(final long chunkKey) {
|
|
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
|
+ return this.getHandle().chunkLoader.getSentChunksRaw().contains(chunkKey);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public Player.Spigot spigot()
|
|
{
|
|
return this.spigot;
|