3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-14 20:10:05 +01:00
Paper/patches/server/1039-API-for-checking-sent-chunks.patch

47 Zeilen
2.1 KiB
Diff

2024-04-20 19:56:59 +02:00
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/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 73ee1ba0b70859cc9c012ab32ad04e8ae2a73e30..92fb2f976ae1c36b152733c28f223337e7f8632e 100644
2024-04-20 19:56:59 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3498,6 +3498,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2024-04-20 19:56:59 +02:00
}
// 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(
2024-06-15 19:24:11 +02:00
+ this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().clone()
2024-04-20 19:56:59 +02:00
+ );
+ }
+
+ @Override
+ public Set<org.bukkit.Chunk> getSentChunks() {
+ org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
2024-06-15 19:24:11 +02:00
+ final it.unimi.dsi.fastutil.longs.LongOpenHashSet rawChunkKeys = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw();
2024-04-20 19:56:59 +02:00
+ 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();
+
2024-06-15 19:24:11 +02:00
+ final it.unimi.dsi.fastutil.longs.LongIterator iter = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().longIterator();
2024-04-20 19:56:59 +02:00
+ 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");
2024-06-15 19:24:11 +02:00
+ return this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey);
2024-04-20 19:56:59 +02:00
+ }
+ // Paper end
+
public Player.Spigot spigot()
{
return this.spigot;