Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Bossbars

Shane Bee edited this page Oct 30, 2023 · 5 revisions

Bossbars are a way to add a bit more pizzazz to your server by providing a different way of displaying information, in the form of a colored bar at the top of your screen.

Creating a Bossbar

Bossbars can be created using a relatively short expression, each component will be explained below:

[new] boss[ ]bar named %string% [with title %string%] [with color %color%] [with style %bossbarstyle%] [with progress %number%]

Bossbar Name

The name is simply used as a way to reference the bossbar, for example, if you choose to delete the bossbar you can use:

delete bossbar named "myCoolBar"

Bossbar Title

The title is what is actually shown to the user above the bar:

set {_myBar} to bossbar named "myCoolBar" with title "&aHello &bWorld!"

Bossbar Color

The color defines the color of the bar, Minecraft only offers a few colors to choose from so don't be picky:

set {_myBar} to bossbar named "myCoolBar" with title "&aHello &bWorld!" with color blue

The colors offered are:

  • blue
  • green
  • pink
  • purple
  • red
  • white
  • yellow

Bossbar Style

The style of the bar changes how it looks a bit, like colors you only have a few options.

set {_myBar} to bossbar named "myCoolBar" with title "&aHello &bWorld!" with color blue with style segmented 6

The styles offered are:

  • segmented 6
  • segmented 10
  • segmented 12
  • segmented 20
  • solid bar

Segmented simply means that the bar has that many darkened dividers evenly placed on the bar, and of course solid bar means there are no dividers.

Bossbar Progress

With bossbars being... bossbars that also means that the progress of them can be changed (how full the bar is), in SkBee, the progression is measured from 0 to 100.

set {_myBar} to bossbar named "myCoolBar" with title "&aHello &bWorld!" with color blue with style segmented 6 with progress 50

Editing an existing Bossbar

After creating a base bossbar (like the examples above) or as just a plain bossbar with set {_myBar} to bossbar named "myCoolBar", you can now edit the individual properties of the bossbar with their own expressions:

  • [boss[ ]]bar title of %bossbar%
  • [boss[ ]]bar color of %bossbar%
  • [boss[ ]]bar style of %bossbar%
  • [boss[ ]]bar progress of %bossbar%
  • [boss[ ]]bar players of %bossbar%
  • [boss[ ]]bar flag %bossbarflag% of %bossbar%
  • [boss[ ]]bar visibility of %bossbar%

The first 4 things were already discussed in the previous section, so now we can introduce the 3 remaining.

Players of a Bossbar

Now you may be wondering, after trying the examples shown, why does the bar not appear? Simply, no one was added to the bar so it's not being shown to anyone. The bossbar players expression represents a list of players who will be shown the bar, so typical Skript syntax will work like expected:

set bossbar players of {_myBar} to player
add {_player} to bossbar players of {_myBar}

Bossbar Visibility

After adding players to a bossbar, you may want to keep them added to that bar, but you also want to hide the bar. That's when this expression is handy, it simply allows you to change the visibility state of a bossbar:

set bossbar visibility of {_myBar} to false

Bossbar Flags

Not as widely used as the other expressions, but it still has its place. The bossbar flag expression lets you adjust a few options for the bar:

set bossbar flag create fog of {_myBar} to true

The options for flags are as follows:

  • create fog
  • darken sky
  • play boss music

Which should be self explanatory based on the names.

Popular Use Cases

Linking a Bossbar to the Health of an Entity

So you want to add a bossbar and have the progress linked to the health of something huh? Well luckily that's very easy to do, first we need to understand what we actually want to do before we go off writing code.

If we know that the range of a bossbar is from 0 to 100, and that the health of the entity we want is, lets say, 0 to 10 (as in 10 hearts), then we need a way to convert the range of the entity to the range of the bossbar, in this case it's very simple, we just need to multiply the health of the entity by 10, but what if we dont want to hardcode that? Then we can write a very simple equation, 100 / maxHealth * currentHealth which will spit out the value we need for the progression.

set bossbar progress of {_myBar} to 100 / max health of {_entity} * health of {_entity}

Now, if you wanted to make the code more efficient you would add it in the damage and heal event, but that's out of scope for this wiki.

Clone this wiki locally