Class GlowEntityCleanup

java.lang.Object
me.tayebyassine.homestead.borders.glow.GlowEntityCleanup

public final class GlowEntityCleanup extends Object
Lifecycle helper for the glowing border display entities spawned by ChunkGlowSpawner and SelectedAreaGlowSpawner.

Every marker carries two persistent data tags: homestead_border_glow, which marks it as plugin-owned, and homestead_border_viewer, the UUID of the player the border is for. Because markers are real world entities, they must be explicitly hidden from every player other than their viewer, otherwise one player's /hs borders would render for the whole server. The same tags let the plugin sweep away leftovers persisted by older plugin versions, remove a single player's markers on demand, and drop stale scoreboard glow-team memberships.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    hideFromEveryoneBut(org.bukkit.entity.Entity entity, UUID viewerId)
    Hides a marker from every online player except its viewer.
    static boolean
    isGlowEntity(org.bukkit.entity.Entity entity)
    Checks whether an entity is one of the plugin's glowing border markers.
    static int
    removeOwnedBy(UUID viewerId)
    Sweeps every currently loaded world and removes only the border glow entities belonging to the given player.
    static int
    removeTagged(Collection<? extends org.bukkit.entity.Entity> entities)
    Removes every tagged border glow entity from the given collection.
    static int
    removeTagged(org.bukkit.entity.Entity[] entities)
    Removes every tagged border glow entity from the given array.
    static int
    Sweeps every currently loaded world and removes all leftover border glow entities, regardless of which player they belong to.
    static void
    tagViewer(org.bukkit.entity.Entity entity, UUID viewerId)
    Records which player a marker was spawned for.
    static UUID
    viewerOf(org.bukkit.entity.Entity entity)
    Reads the viewer UUID recorded on a marker.

    Methods inherited from class Object

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

    • isGlowEntity

      public static boolean isGlowEntity(org.bukkit.entity.Entity entity)
      Checks whether an entity is one of the plugin's glowing border markers.
      Parameters:
      entity - the entity to check; null-safe
      Returns:
      true if the entity carries the border glow tag
    • tagViewer

      public static void tagViewer(org.bukkit.entity.Entity entity, UUID viewerId)
      Records which player a marker was spawned for.
      Parameters:
      entity - the marker to tag
      viewerId - the UUID of the player the border belongs to
    • viewerOf

      public static UUID viewerOf(org.bukkit.entity.Entity entity)
      Reads the viewer UUID recorded on a marker.
      Parameters:
      entity - the marker to inspect
      Returns:
      the viewer's UUID, or null if the marker carries no viewer tag
    • hideFromEveryoneBut

      public static void hideFromEveryoneBut(org.bukkit.entity.Entity entity, UUID viewerId)
      Hides a marker from every online player except its viewer.

      Marker entities exist in the world for all clients by default; the per-player visibility API is what keeps one player's border private to that player.

      Parameters:
      entity - the marker to hide
      viewerId - the UUID of the only player who should see it
    • removeTagged

      public static int removeTagged(Collection<? extends org.bukkit.entity.Entity> entities)
      Removes every tagged border glow entity from the given collection.

      Also drops the entity from any homestead_glow_* scoreboard team so that stale team entries are not persisted. Failures on individual entities are ignored.

      Parameters:
      entities - the entities to filter and remove
      Returns:
      the number of entities actually removed
    • removeTagged

      public static int removeTagged(org.bukkit.entity.Entity[] entities)
      Removes every tagged border glow entity from the given array.
      Parameters:
      entities - the entities to filter and remove
      Returns:
      the number of entities actually removed
      See Also:
    • sweepLoadedWorlds

      public static int sweepLoadedWorlds()
      Sweeps every currently loaded world and removes all leftover border glow entities, regardless of which player they belong to.

      Invoked once on startup, before any border task can be running, so it only ever touches entities persisted by a previous server session.

      Returns:
      the number of entities removed
    • removeOwnedBy

      public static int removeOwnedBy(UUID viewerId)
      Sweeps every currently loaded world and removes only the border glow entities belonging to the given player.

      Parameters:
      viewerId - the UUID of the player whose markers should be removed
      Returns:
      the number of entities removed