-
-
Notifications
You must be signed in to change notification settings - Fork 19
Bossbars
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.
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%]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"The title is what is actually shown to the user above the bar:
set {_myBar} to bossbar named "myCoolBar" with title "&aHello &bWorld!"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 blueThe colors offered are:
bluegreenpinkpurpleredwhiteyellow
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 6The styles offered are:
segmented 6segmented 10segmented 12segmented 20solid 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.
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 50After 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.
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 playeradd {_player} to bossbar players of {_myBar}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 falseNot 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 trueThe options for flags are as follows:
create fogdarken skyplay boss music
Which should be self explanatory based on the names.
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.