#1018: Add methods to get players seeing specific chunks

By: MetallicGoat <the.great.metallic.goat@gmail.com>
This commit is contained in:
Bukkit/Spigot 2024-06-08 09:03:39 +10:00
parent 3dcb0dfc9a
commit b4ac71a201
2 changed files with 39 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.generator.structure.GeneratedStructure;
import org.bukkit.generator.structure.Structure;
import org.bukkit.persistence.PersistentDataHolder;
@ -285,6 +286,17 @@ public interface Chunk extends PersistentDataHolder {
@NotNull
Collection<GeneratedStructure> getStructures(@NotNull Structure structure);
/**
* Get a list of all players who are can view the chunk from their client
* <p>
* This list will be empty if no players are viewing the chunk, or the chunk
* is unloaded.
*
* @return collection of players who can see the chunk
*/
@NotNull
public Collection<Player> getPlayersSeeingChunk();
/**
* An enum to specify the load level of a chunk.
*/

View File

@ -314,6 +314,33 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Deprecated
public boolean refreshChunk(int x, int z);
/**
* Get a list of all players who are can view the specified chunk from their
* client
* <p>
* This list will be empty if no players are viewing the chunk, or the chunk
* is unloaded.
*
* @param chunk the chunk to check
* @return collection of players who can see the chunk
*/
@NotNull
public Collection<Player> getPlayersSeeingChunk(@NotNull Chunk chunk);
/**
* Get a list of all players who are can view the specified chunk from their
* client
* <p>
* This list will be empty if no players are viewing the chunk, or the chunk
* is unloaded.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return collection of players who can see the chunk
*/
@NotNull
public Collection<Player> getPlayersSeeingChunk(int x, int z);
/**
* Gets whether the chunk at the specified chunk coordinates is force
* loaded.