Class ChunkGlowSpawner
This class manages the visual representation of region borders using BlockDisplay
entities (iron chains for edges, copper grates for corners). It efficiently computes
exterior edges and corners of claimed chunk regions and renders them as glowing blocks.
The corner detection algorithm counts connected edges at each chunk boundary intersection. A corner is rendered only if it has 2 or more connected edges, which correctly handles complex region shapes including squares, L-shapes, T-junctions, and other configurations.
Each player can have at most one active glowing task. The task auto-cancels after a configurable timeout (default 3 minutes) to prevent resource leaks.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionChunkGlowSpawner(org.bukkit.entity.Player player) Creates a new chunk glow spawner for the given player. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcancelTask(org.bukkit.entity.Player player) Cancels the glow task and removes all spawned entities for the given player.static TaskHandlegetTask(org.bukkit.entity.Player player) Gets the active task handle for the given player, if any.static voidhideForeignTo(org.bukkit.entity.Player viewer) Hides every other player's border markers from the given viewer.static booleanisTaskRunning(org.bukkit.entity.Player player) Checks if a glow task is currently running for the given player.static voidCancels every running glow task and removes all tracked entities synchronously.voidSpawns or refreshes the glowing border for all regions in the player's world.
-
Constructor Details
-
ChunkGlowSpawner
public ChunkGlowSpawner(org.bukkit.entity.Player player) Creates a new chunk glow spawner for the given player.- Parameters:
player- the player to show borders for; must not be null- Throws:
IllegalArgumentException- if player is null
-
-
Method Details
-
cancelTask
public static void cancelTask(org.bukkit.entity.Player player) Cancels the glow task and removes all spawned entities for the given player. Safe to call multiple times; no-op if no task is running.- Parameters:
player- the player whose border glow should be cancelled; null-safe
-
shutdownAll
public static void shutdownAll()Cancels every running glow task and removes all tracked entities synchronously.Called while the plugin is being disabled, when no further tasks can be scheduled, so entities must be removed on the calling thread directly.
-
isTaskRunning
public static boolean isTaskRunning(org.bukkit.entity.Player player) Checks if a glow task is currently running for the given player.- Parameters:
player- the player to check; null-safe- Returns:
- true if a border glow task is active for this player
-
hideForeignTo
public static void hideForeignTo(org.bukkit.entity.Player viewer) Hides every other player's border markers from the given viewer.Marker visibility is only applied when entities spawn, so it must be re-applied whenever a player joins the server.
- Parameters:
viewer- the player who must not see other players' borders; null-safe
-
getTask
Gets the active task handle for the given player, if any.- Parameters:
player- the player to get the task for; null-safe- Returns:
- the task handle, or null if no task is running
-
spawnGlow
public void spawnGlow()Spawns or refreshes the glowing border for all regions in the player's world.Runs asynchronously. Computes a hash of all regions in the player's world and only re-spawns entities if the region layout has changed. Otherwise, just refreshes the glowing effect on existing entities.
-