Class RareEntityBossBar

java.lang.Object
valorless.rarespawns.datamodels.RareEntityBossBar

public class RareEntityBossBar extends Object
Represents a boss bar for a rare entity in RareSpawns. Handles creation, updating, and removal of the boss bar, including health syncing and player visibility. Boss bars are shown to nearby players and automatically removed when the entity dies, is tamed, or no players are nearby.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The Bukkit runnable task ID for updating the boss bar.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RareEntityBossBar(org.bukkit.entity.LivingEntity rareEntity)
    Constructs a RareEntityBossBar for the given rare entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the boss bar for all players and cleans up.
    void
    Shows the boss bar to all players near the rare entity.
    void
    Updates the boss bar health to match the rare entity's health.

    Methods inherited from class java.lang.Object

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

    • runnable

      public Integer runnable
      The Bukkit runnable task ID for updating the boss bar.
  • Constructor Details

    • RareEntityBossBar

      public RareEntityBossBar(org.bukkit.entity.LivingEntity rareEntity)
      Constructs a RareEntityBossBar for the given rare entity. Creates the boss bar, sets its properties, and schedules updates. Automatically removes the boss bar if the entity dies, is tamed, or no players are nearby.
      Parameters:
      rareEntity - The rare entity to attach the boss bar to.
  • Method Details

    • updateHealth

      public void updateHealth()
      Updates the boss bar health to match the rare entity's health. Sets the boss bar progress as a percentage of current health to max health.
    • showToNearbyPlayers

      public void showToNearbyPlayers()
      Shows the boss bar to all players near the rare entity. Adds/removes players from the boss bar based on their proximity.
    • remove

      public void remove()
      Removes the boss bar for all players and cleans up. Clears the viewers set and removes the boss bar from all players.