A serverside user interface library for Minecraft: Java Edition
—
Boss bar display system with customizable appearance, progress tracking, and viewer management. Boss bars provide prominent visual feedback for ongoing events or status information.
Core interface for creating and managing boss bars with configurable properties.
/**
* Represents a boss bar with title, progress, color, and flags
*/
interface BossBar extends Examinable {
/**
* Gets the boss bar title
* @return the title component
*/
Component name();
/**
* Gets the progress value (0.0-1.0)
* @return the progress
*/
float progress();
/**
* Gets the boss bar color
* @return the color
*/
Color color();
/**
* Gets the boss bar overlay style
* @return the overlay
*/
Overlay overlay();
/**
* Gets the boss bar flags
* @return set of flags
*/
Set<Flag> flags();
/**
* Sets the boss bar title
* @param name the new title
* @return boss bar with new title
*/
BossBar name(ComponentLike name);
/**
* Sets the progress value
* @param progress the progress (0.0-1.0)
* @return boss bar with new progress
*/
BossBar progress(float progress);
/**
* Sets the boss bar color
* @param color the color
* @return boss bar with new color
*/
BossBar color(Color color);
/**
* Sets the boss bar overlay
* @param overlay the overlay
* @return boss bar with new overlay
*/
BossBar overlay(Overlay overlay);
/**
* Sets the boss bar flags
* @param flags the flags
* @return boss bar with new flags
*/
BossBar flags(Set<Flag> flags);
/**
* Adds flags to the boss bar
* @param flags the flags to add
* @return boss bar with added flags
*/
BossBar addFlags(Flag... flags);
/**
* Removes flags from the boss bar
* @param flags the flags to remove
* @return boss bar with removed flags
*/
BossBar removeFlags(Flag... flags);
/**
* Checks if the boss bar has a flag
* @param flag the flag to check
* @return true if flag is present
*/
boolean hasFlag(Flag flag);
/**
* Creates a boss bar
* @param name the title
* @param progress the progress (0.0-1.0)
* @param color the color
* @param overlay the overlay
* @return new boss bar
*/
static BossBar bossBar(ComponentLike name, float progress, Color color, Overlay overlay);
/**
* Creates a boss bar with flags
* @param name the title
* @param progress the progress
* @param color the color
* @param overlay the overlay
* @param flags the flags
* @return new boss bar
*/
static BossBar bossBar(ComponentLike name, float progress, Color color, Overlay overlay, Set<Flag> flags);
/**
* Boss bar colors
*/
enum Color {
PINK("pink"),
BLUE("blue"),
RED("red"),
GREEN("green"),
YELLOW("yellow"),
PURPLE("purple"),
WHITE("white");
}
/**
* Boss bar overlay styles (segment divisions)
*/
enum Overlay {
PROGRESS("progress"), // Solid bar
NOTCHED_6("notched_6"), // 6 segments
NOTCHED_10("notched_10"), // 10 segments
NOTCHED_12("notched_12"), // 12 segments
NOTCHED_20("notched_20"); // 20 segments
}
/**
* Boss bar behavior flags
*/
enum Flag {
DARKEN_SCREEN("darken_screen"), // Darkens the sky
PLAY_BOSS_MUSIC("play_boss_music"), // Plays boss music
CREATE_WORLD_FOG("create_world_fog"); // Creates fog effect
}
}Usage Examples:
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
// Simple boss bar
BossBar healthBar = BossBar.bossBar(
Component.text("Boss Health"),
0.75f, // 75% health
BossBar.Color.RED,
BossBar.Overlay.PROGRESS
);
// Show to audience
audience.showBossBar(healthBar);
// Update progress over time
healthBar = healthBar.progress(0.5f); // 50% health
// Complex boss bar with effects
BossBar dramaticBossBar = BossBar.bossBar(
Component.text("The Ender Dragon", NamedTextColor.DARK_PURPLE),
1.0f,
BossBar.Color.PURPLE,
BossBar.Overlay.NOTCHED_20,
Set.of(BossBar.Flag.DARKEN_SCREEN, BossBar.Flag.PLAY_BOSS_MUSIC)
);
// Hide boss bar
audience.hideBossBar(healthBar);Install with Tessl CLI
npx tessl i tessl/maven-net-kyori--adventure-api