Class Bossbar
java.lang.Object
tk.airshipcraft.commonlib.gui.objects.Bossbar
Encapsulates the Bukkit API's BossBar feature, offering a simplified and enhanced interface for creating and manipulating boss bars.
This class includes utility methods for animating boss bar progress, flashing the bar, updating its appearance after a delay,
and adding emojis to the title, providing a richer in-game experience.
- Since:
- 2023-04-11
- Version:
- 1.0.0
- Author:
- Locutusque, notzune
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEmojiToTitle
(String emoji) Adds an emoji or special character to the beginning of the boss bar's title.void
addPlayer
(org.bukkit.entity.Player player) Adds a player to this boss bar, making it visible to them.void
animateProgress
(double progress, int duration) Animates the progress of the boss bar from its current value to a specified target value over a given duration.void
flash
(int duration) Flashes the boss bar by alternating its color and style at regular intervals for a specified duration.void
removePlayer
(org.bukkit.entity.Player player) Removes a player from this boss bar, hiding it from their view.void
updateAfterDelay
(org.bukkit.boss.BarColor color, org.bukkit.boss.BarStyle style, long delay) Updates the color and style of the boss bar after a specified delay.
-
Constructor Details
-
Bossbar
Constructs a new Bossbar instance with the specified title, color, and style.- Parameters:
title
- The title text of the boss bar.color
- The color of the boss bar, using BarColor.style
- The style of the boss bar, using BarStyle.
-
-
Method Details
-
addPlayer
public void addPlayer(org.bukkit.entity.Player player) Adds a player to this boss bar, making it visible to them.- Parameters:
player
- The Player to add to the boss bar's visibility.
-
removePlayer
public void removePlayer(org.bukkit.entity.Player player) Removes a player from this boss bar, hiding it from their view.- Parameters:
player
- The Player to remove from the boss bar's visibility.
-
animateProgress
public void animateProgress(double progress, int duration) Animates the progress of the boss bar from its current value to a specified target value over a given duration. The animation is achieved by gradually updating the progress value at regular intervals.- Parameters:
progress
- The target progress value to animate to (between 0.0 and 1.0).duration
- The duration in game ticks over which to animate the progress.
-
flash
public void flash(int duration) Flashes the boss bar by alternating its color and style at regular intervals for a specified duration. This effect creates a noticeable flashing animation to draw players' attention.- Parameters:
duration
- The duration in ticks for which the boss bar should flash.
-
updateAfterDelay
public void updateAfterDelay(org.bukkit.boss.BarColor color, org.bukkit.boss.BarStyle style, long delay) Updates the color and style of the boss bar after a specified delay. This method allows for delayed customization of the boss bar's appearance.- Parameters:
color
- The new color to set for the boss bar, using BarColor.style
- The new style to set for the boss bar, using BarStyle.delay
- The delay in ticks before applying the new color and style.
-
addEmojiToTitle
Adds an emoji or special character to the beginning of the boss bar's title. This method is useful for adding visual flair or emphasizing the boss bar's message.- Parameters:
emoji
- The emoji or character string to prepend to the boss bar's title.
-