Class SelectedAreaGlowSpawner
This class renders a 3D cuboid wireframe using BlockDisplay entities
(iron chains for edges on X, Y, and Z axes, copper grates for all 8 corners).
It's used for visual feedback when players are selecting sub-areas or regions.
The cuboid is defined by two corner blocks (first and second selection points). The spawner computes all 12 edges and 8 corners of the axis-aligned bounding box between these points and renders them as glowing blocks.
Task auto-cancels after 1 minute to prevent resource leaks from abandoned selections.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSelectedAreaGlowSpawner(org.bukkit.entity.Player player, SeBlock firstBlock, SeBlock secondBlock) Creates a new selection area glow spawner.SelectedAreaGlowSpawner(org.bukkit.entity.Player player, org.bukkit.block.Block firstBlock, org.bukkit.block.Block secondBlock) Creates a new selection area glow spawner using Bukkit blocks. -
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 SelectedAreaGlowSpawnergetSpawner(org.bukkit.entity.Player player) Gets the active spawner 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 cuboid border for the current selection.static voidupdateSelection(org.bukkit.entity.Player player, SeBlock firstBlock, SeBlock secondBlock) Updates the selection bounds for an existing spawner.
-
Constructor Details
-
SelectedAreaGlowSpawner
public SelectedAreaGlowSpawner(org.bukkit.entity.Player player, org.bukkit.block.Block firstBlock, org.bukkit.block.Block secondBlock) Creates a new selection area glow spawner using Bukkit blocks.- Parameters:
player- the player to show borders for; must not be nullfirstBlock- first corner block of the selectionsecondBlock- second corner block of the selection- Throws:
IllegalArgumentException- if player is null
-
SelectedAreaGlowSpawner
public SelectedAreaGlowSpawner(org.bukkit.entity.Player player, SeBlock firstBlock, SeBlock secondBlock) Creates a new selection area glow spawner.- Parameters:
player- the player to show borders for; must not be nullfirstBlock- first corner of the selection cuboidsecondBlock- second corner of the selection cuboid- 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.- 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
-
getSpawner
Gets the active spawner for the given player, if any.- Parameters:
player- the player to get the spawner for; null-safe- Returns:
- the spawner instance, or null if no task is running
-
updateSelection
public static void updateSelection(org.bukkit.entity.Player player, SeBlock firstBlock, SeBlock secondBlock) Updates the selection bounds for an existing spawner.If a spawner is running for the player, updates its corner blocks. The new selection will be rendered on the next task iteration.
- Parameters:
player- the player whose selection to updatefirstBlock- new first cornersecondBlock- new second corner
-
spawnGlow
public void spawnGlow()Spawns or refreshes the glowing cuboid border for the current selection.Computes a hash of the two corner blocks and only re-spawns entities if the selection has changed. Otherwise, just refreshes the glowing effect on existing entities. Runs asynchronously for region/hash computation, then schedules entity spawning on the main thread.
-