# Boss Bars

> Object-oriented boss bar management with the Kore OOP module - register, configure, show, hide, and update boss bars.

Updated 2026-10-07. Canonical: https://kore.ayfri.com/docs/oop/boss-bars

The OOP module wraps [Minecraft boss bars](https://minecraft.wiki/w/Commands/bossbar) into a simple
config + handle pattern.

This is useful when you want one place to configure a bar and then reuse it across multiple gameplay functions.

`BossBarConfig` stores the initial registration settings, while `BossBarHandle` exposes the runtime commands you call
from functions.

> [!FOOTPRINT]
> - **Objectives:** none.
> - **Storage:** none.
> - **Entities:** none.
> - **Forceloaded chunks:** none.
> - **Every tick:** no.
> - **Load and files:** `bossbar_<id>_init` creates the boss bar `<namespace>:<id>` (namespace `minecraft` by default) and applies its settings on every load.

## Registering a boss bar

```kotlin
val bar = registerBossBar("my_bar", name) {
	color = BossBarColor.RED
	max = 200
	style = BossBarStyle.NOTCHED_10
	value = 50
}
```

A load function is generated that creates the bar and applies all initial settings.

## Typical workflow

```kotlin
function("show_phase_bar") {
	bar.apply {
		setPlayers(player)
		setValue(150)
		show()
	}
}

function("hide_phase_bar") {
	bar.hide()
}
```

In practice, boss bars often pair well with timers, boss fights, or round-based activities where the bar is configured
once and then updated from several different functions.

## Manipulating a boss bar

```kotlin
function("boss_fight") {
	bar.apply {
		setValue(100)
		setColor(BossBarColor.BLUE)
		setPlayers(player)
		show()
		hide()
		remove()
	}
}
```

You can also target all members of a team:

```kotlin
bar.apply {
	setPlayers(team)
	setStyle(BossBarStyle.NOTCHED_12)
}
```

## Configuration vs handle methods

`BossBarConfig` controls the values that are written when the bar is registered:

- `color`
- `displayName`
- `max`
- `style`
- `value`
- `visible`

`BossBarHandle` exposes the runtime methods listed below.

## Function reference

| Function             | Description                                      |
|----------------------|--------------------------------------------------|
| `hide`               | Hide the bar without deleting its configuration  |
| `remove`             | Remove the boss bar entirely                     |
| `setColor`           | Change the boss bar color                        |
| `setMax`             | Update the maximum value used to render progress |
| `setName`            | Change the displayed boss bar name               |
| `setPlayers(entity)` | Control which players currently see the bar      |
| `setPlayers(team)`   | Show the bar to every member of a team           |
| `setStyle`           | Change the boss bar rendering style              |
| `setValue`           | Update the current boss bar value                |
| `show`               | Make the bar visible to the assigned players     |
