aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0468-API-for-checking-sent-chunks.patch
blob: 8d97e181b05bfa6f437f444d037f5ae57fbdc003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Flo0 <flo.roma@web.de>
Date: Mon, 8 Apr 2024 16:22:07 +0200
Subject: [PATCH] API for checking sent chunks


diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index f08b1a2ec8815efcaaf1371e20eb1461a5f2d359..8a1e39474af88188f2e1765731b57d349f0ee645 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -3751,6 +3751,47 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
     void resetIdleDuration();
     // Paper end
 
+    // Paper start - Add chunk view API
+    /**
+     * Gets the a set of chunk keys for all chunks that have been sent to the player.
+     *
+     * @return an immutable set of chunk keys
+     * @apiNote currently marked as experimental to gather feedback regarding the returned set being an immutable copy
+     * vs it potentially being an unmodifiable view of the set chunks.
+     */
+    @ApiStatus.Experimental
+    java.util.@NotNull @org.jetbrains.annotations.Unmodifiable Set<Long> getSentChunkKeys();
+
+    /**
+     * Gets the set of chunks that have been sent to the player.
+     *
+     * @return an immutable set of chunks
+     * @apiNote currently marked as experimental to gather feedback regarding the returned set being an immutable copy
+      * vs it potentially being an unmodifiable view of the set chunks.
+     */
+    @ApiStatus.Experimental
+    java.util.@NotNull @org.jetbrains.annotations.Unmodifiable Set<org.bukkit.Chunk> getSentChunks();
+
+    /**
+     * Checks if the player has been sent a specific chunk.
+     *
+     * @param chunk the chunk to check
+     * @return true if the player has been sent the chunk, false otherwise
+     */
+    default boolean isChunkSent(@NotNull org.bukkit.Chunk chunk) {
+        return this.isChunkSent(chunk.getChunkKey());
+    }
+
+    /**
+     * Checks if the player has been sent a specific chunk.
+     *
+     * @param chunkKey the chunk key to check
+     * @return true if the player has been sent the chunk, false otherwise
+     * @see org.bukkit.Chunk#getChunkKey()
+     */
+    boolean isChunkSent(long chunkKey);
+    // Paper end
+
     @NotNull
     @Override
     Spigot spigot();