Boss Bars

The OOP module wraps Minecraft boss bars 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.

Registering a boss bar

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

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

Typical workflow

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

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

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

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

You can also target all members of a team:

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

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