Boss bar display API
BossBar
A BossBar is the bar displayed at the top of the screen (like the Ender Dragon or Wither health bar). You can create custom boss bars with custom titles, colors, and progress.
Class Methods
create
bar = BossBar.create(title, color=None, style=None, players=None)
Create a new boss bar. This is synchronous.
- Parameters:
title(str) — Bar title text. Supports§color codes.color(BarColor| None) — Bar color. DefaultNone(PINK).style(BarStyle| None) — Bar segmentation style. DefaultNone(SOLID).players(list[Player] | None) — Players who can see the bar. DefaultNone.- Returns:
BossBar
bar = BossBar.create(
"§c§lRaid Boss",
color=BarColor.RED,
style=BarStyle.SEGMENTED_10
)
Attributes
title
- Type:
str
Current title text.
progress
- Type:
float
Progress value from 0.0 (empty) to 1.0 (full).
color
- Type:
BarColor
Current bar color.
style
- Type:
BarStyle
Current segmentation style.
visible
- Type:
bool
Whether the bar is currently visible.
Methods
add_player
await bar.add_player(player)
Show this bar to a player.
- Parameters:
player(Player) — Player to add.- Returns:
Awaitable[None]
remove_player
await bar.remove_player(player)
Hide this bar from a player.
- Parameters:
player(Player) — Player to remove.- Returns:
Awaitable[None]
set_title
await bar.set_title(title)
Change the bar title.
- Parameters:
title(str) — New title text.- Returns:
Awaitable[None]
set_progress
await bar.set_progress(value)
Set the bar progress.
- Parameters:
value(float) — Progress from 0.0 to 1.0.- Returns:
Awaitable[None]
await bar.set_progress(0.5) # Half full
set_color
await bar.set_color(color)
Change the bar color.
- Parameters:
color(BarColor) — New color.- Returns:
Awaitable[None]
set_style
await bar.set_style(style)
Change the bar segmentation style.
- Parameters:
style(BarStyle) — New style.- Returns:
Awaitable[None]
set_visible
await bar.set_visible(value)
Show or hide the bar without removing players.
- Parameters:
value(bool) — Visibility.- Returns:
Awaitable[None]
BarColor Options
| Name | Description |
|---|---|
PINK |
Default pink |
BLUE |
Blue |
RED |
Red |
GREEN |
Green |
YELLOW |
Yellow |
PURPLE |
Purple |
WHITE |
White |
BarStyle Options
| Name | Description |
|---|---|
SOLID |
No segments |
SEGMENTED_6 |
6 segments |
SEGMENTED_10 |
10 segments |
SEGMENTED_12 |
12 segments |
SEGMENTED_20 |
20 segments |
Example: Health bar for a boss fight
from bridge import *
boss_bar = BossBar.create("§c§lDragon §7- §c100%", color=BarColor.RED, style=BarStyle.SEGMENTED_10)
@event
async def entity_damage(e: Event):
entity = e.entity
if entity.custom_name == "Dragon":
hp_pct = entity.health / 100
await boss_bar.set_progress(hp_pct)
await boss_bar.set_title(f"§c§lDragon §7- §c{int(hp_pct * 100)}%")
See also: BossBarDisplay for a higher-level wrapper with cooldown linking.