Class SelectedAreaParticlesSpawner

java.lang.Object
tfagaming.projects.minecraft.homestead.borders.SelectedAreaParticlesSpawner

public class SelectedAreaParticlesSpawner extends Object
Handles particle spawning around a selected cuboid area for a specific player.

Each player has at most one persistent task running at any time. If a task is already active when the constructor is called, the selection corners are simply updated in-place; the existing task continues without interruption and will use the new coordinates on its very next tick. This avoids the cancel/restart cycle that was previously a source of lag and task-leak bugs.

Particle spawning runs on the main thread (or the player's entity thread on Folia) to keep all Bukkit API access thread-safe.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SelectedAreaParticlesSpawner(org.bukkit.entity.Player player, org.bukkit.block.Block firstBlock, org.bukkit.block.Block secondBlock)
    Creates or updates the particle spawner for the given player using raw Block corners.
    SelectedAreaParticlesSpawner(org.bukkit.entity.Player player, SeBlock firstBlock, SeBlock secondBlock)
    Creates or updates the particle spawner for the given player using SeBlock corners.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    cancelTask(org.bukkit.entity.Player player)
    Cancels the active particle task for the given player, if any.
    static void
    cancelTask(TaskHandle task, org.bukkit.entity.Player player)
    Cancels the given task handle and removes the associated spawner from the tracking map.
    static boolean
    isTaskRunning(org.bukkit.entity.Player player)
    Returns true if a particle task is currently running for the given player, otherwise false.
    void
    Spawns dust particles along all twelve edges of the selected cuboid.
    void
    Starts the repeating task that drives particle spawning.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SelectedAreaParticlesSpawner

      public SelectedAreaParticlesSpawner(org.bukkit.entity.Player player, org.bukkit.block.Block firstBlock, org.bukkit.block.Block secondBlock)
      Creates or updates the particle spawner for the given player using raw Block corners.
      Parameters:
      player - the player to show the selection border for
      firstBlock - one corner of the selected area
      secondBlock - the opposite corner of the selected area
    • SelectedAreaParticlesSpawner

      public SelectedAreaParticlesSpawner(org.bukkit.entity.Player player, SeBlock firstBlock, SeBlock secondBlock)
      Creates or updates the particle spawner for the given player using SeBlock corners.
      Parameters:
      player - The player to show the selection border for
      firstBlock - One corner of the selected area
      secondBlock - The opposite corner of the selected area
  • Method Details

    • cancelTask

      public static void cancelTask(TaskHandle task, org.bukkit.entity.Player player)
      Cancels the given task handle and removes the associated spawner from the tracking map.
      Parameters:
      task - The task handle to cancel
      player - The player associated with the task
    • cancelTask

      public static void cancelTask(org.bukkit.entity.Player player)
      Cancels the active particle task for the given player, if any.
      Parameters:
      player - The player whose task should be cancelled
    • isTaskRunning

      public static boolean isTaskRunning(org.bukkit.entity.Player player)
      Returns true if a particle task is currently running for the given player, otherwise false.
      Parameters:
      player - The player to check
    • spawnParticles

      public void spawnParticles()
      Spawns dust particles along all twelve edges of the selected cuboid.
    • startRepeatingEffect

      public void startRepeatingEffect()
      Starts the repeating task that drives particle spawning.