Package valorless.rarespawns.datamodels
Class RareEntityBossBar
java.lang.Object
valorless.rarespawns.datamodels.RareEntityBossBar
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 -
Constructor Summary
ConstructorsConstructorDescriptionRareEntityBossBar(org.bukkit.entity.LivingEntity rareEntity) Constructs a RareEntityBossBar for the given rare entity. -
Method Summary
Modifier and TypeMethodDescriptionvoidremove()Removes the boss bar for all players and cleans up.voidShows the boss bar to all players near the rare entity.voidUpdates the boss bar health to match the rare entity's health.
-
Field Details
-
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.
-