Jump to content

Skript-Mirror/Skript-Reflect Bossbar Tutorial


Lynxdeer

Recommended Posts

(I've only tested this on skript-reflect, but given that reflect is a hook it will most likely work the same)

Don't wanna use skellett/skRayFall? Skript-Mirror/Reflect can work too! Full code is at the end if you just want to copy and paste something.

We will need to import the following:

    org.bukkit.boss.BossBar
    org.bukkit.boss.BarColor
    org.bukkit.boss.BarStyle
    org.bukkit.Bukkit


The former being to create the bossbar, the middle two being elements of the constructor element, and the last being so that we can use Bukkit.createBossBar, as {Bukkit}.createBossBar didn't work.

Next, we will need to create the bossbar. We can do so by setting a variable. Note that deleting the variable will not hide the bossbar, so you will have to use {variable}.removeAll() or {variable}.setVisible(false) to hide the bossbar. We can create a bossbar using the following:
 

set {variable} to Bukkit.createBossBar("Text", BarColor.(color), BarStyle.(style))

Text can be anything you want the title to be.
Colors (Must be capital): BLUE, GREEN, PINK, PURPLE, RED, WHITE, YELLOW
Styles: (Must also be capital): SEGMENTED_6 SEGMENTED_10, SEGMENTED_12, SEGMENTED_20, SOLID

Next, you will need to add players and enable visibility. You can do so like this:
 

{variable}.addPlayer(player)
{variable}.setVisible(true)

 

Bossbars will not automatically assign themselves to players. If you would like to show them to every player, you'll do so like this.

loop all players:
	{variable}.addPlayer(loop-player)

 

Now for a few extra things, such as changing the title, color and style after creating the bossbar, and the progress of the bossbar.

{variable}.getProgress()
{variable}.setProgress(number between 0 and 1)

{variable}.getTitle()
{variable}.setTitle("thing")

{variable}.getColor()
{variable}.setColor(BarColor.COLOR)

{variable}.getStyle()
{variable}.setStyle(BarStyle.STYLE)

 

In the end, it ends up looking something like this:

import:
	org.bukkit.boss.BossBar
	org.bukkit.boss.BarColor
	org.bukkit.boss.BarStyle
	org.bukkit.Bukkit

on load:
	{bossbar}.removeAll()
	{bossbar}.setVisible(false)
	delete {bossbar}
	set {bossbar} to Bukkit.createBossBar("&bWelcome to my server!", BarColor.BLUE, BarStyle.SOLID)
	loop all players:
		{bossbar}.addPlayer(loop-player)
	{bossbar}.setVisible(true)
	
on join:
	{bossbar}.addPlayer(player)

Hopefully I helped someone!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...