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.

bar = BossBar.create(
    "§c§lRaid Boss",
    color=BarColor.RED,
    style=BarStyle.SEGMENTED_10
)

Attributes

title

Current title text.

progress

Progress value from 0.0 (empty) to 1.0 (full).

color

Current bar color.

style

Current segmentation style.

visible

Whether the bar is currently visible.


Methods

add_player

await bar.add_player(player)

Show this bar to a player.

remove_player

await bar.remove_player(player)

Hide this bar from a player.

set_title

await bar.set_title(title)

Change the bar title.

set_progress

await bar.set_progress(value)

Set the bar progress.

await bar.set_progress(0.5)  # Half full

set_color

await bar.set_color(color)

Change the bar color.

set_style

await bar.set_style(style)

Change the bar segmentation style.

set_visible

await bar.set_visible(value)

Show or hide the bar without removing players.


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.