Skip to content

Server_Bossbar

Legopitstop edited this page May 28, 2021 · 2 revisions

This datapack adds in a boss bar that is used on most/all servers if you want a vanilla-like server or you don't like plugins install this simple datapack to get a cool look to your server. It could even be in a single-player world!

Features

  • Config to customize your experience.
  • Easy to use API
  • Works out-of-box (it's recommended to customize to your use.)

API

You can edit the bossbar via the API, The file can be found: <datapack>/data/custom/functions/bossbar.mcfunction

Example in JSON: (This is not the proper format, just JSON looks nicer)

// storage bossbar:api
{
    // #optional. The parent properties to apply to all "bossbar" values. note that values inside "bossbar" can still overide parent values. Unless override is set to true.
    "parent": {
        "display_name": "{\"text\":\"Server\"}",
        "display_time": 100,
        "display_percent": false,
        // (Boolean) When true it will override all values inside "bossbar" Default: false (only for parent)
        "override": false,
        "color": "white",
        "style": "progress",
        "value": 1
    },
    // #required. All the properties of the bossbar, each item is a new frame, max of 64 frames.
    "bossbar": [
        {
            // (RAW JSON) #optional The text to display at the top of the bossbar. Default: Server
            "display_name": "{\"text\":\"Server\"}",
            // (Int) #required The amount of ticks to show the text. Default: 100t = 5s
            "display_time": 100,
            // (Boolean|Enum) #optional Display the percent of the bossbar. Excepted values; true (displays to right), false (does not use), "left" (displays to the left), "right" (displays to the right) Default: false
            "display_percent": false,
            // (Enum) #optional The color of the bossbar (This will not effect the color of the text) Default: white
            "color": "white",
            // (Enum) #optional The style of the bossbar Valid: progress, notched_10, notched_12, notched_20, notched_6. Default: progress
            "style": "progress",
            // (Int|Enum) #optional The value of the bossbar (how much the bar is filled out of 100) excepts: "random" Will choose a random number 0-100, "auto" Will find the max number of bossbars, and display the corresponding percent Default: 0
            "value": 1
        }
    ]
}

Default File (in proper format)

# Parent: Apply properties to all frames With optional override capeability.
data modify storage bossbar:api parent set value {display_time: 20, value: "auto", style: "notched_10"}

# Bossbar: Contains all the frames (up to 64!)
data modify storage bossbar:api bossbar insert 0 value {display_name: '{"text":"Welcome!","color":"dark_blue"}', color: "blue"}
data modify storage bossbar:api bossbar insert 1 value {display_name: '{"text":"Welcome!","color":"dark_blue"}', color: "blue"}
data modify storage bossbar:api bossbar insert 2 value {display_name: '{"text":"legopitstop.weebly.com","color":"dark_green"}', color: "green"}
data modify storage bossbar:api bossbar insert 3 value {display_name: '{"text":"legopitstop.weebly.com","color":"dark_green"}', color: "green"}
data modify storage bossbar:api bossbar insert 4 value {display_name: '{"text":"custom bossbar","color":"red"}', color: "pink"}
data modify storage bossbar:api bossbar insert 5 value {display_name: '{"text":"custom bossbar","color":"red"}', color: "pink"}
data modify storage bossbar:api bossbar insert 6 value {display_name: '{"text":"Is this cool or what?","color":"dark_purple"}', color: "purple"}
data modify storage bossbar:api bossbar insert 7 value {display_name: '{"text":"Is this cool or what?","color":"dark_purple"}', color: "purple"}
data modify storage bossbar:api bossbar insert 8 value {display_name: '{"text":"Easy to learn API!","color":"dark_red"}', color: "red"}
data modify storage bossbar:api bossbar insert 9 value {display_name: '{"text":"Easy to learn API!","color":"dark_red"}', color: "red"}
data modify storage bossbar:api bossbar insert 10 value {display_name: '{"text":"Up to 64 custom frames!","color":"gray"}', color: "white"}
data modify storage bossbar:api bossbar insert 11 value {display_name: '{"text":"Up to 64 custom frames!","color":"gray"}', color: "white"}
data modify storage bossbar:api bossbar insert 12 value {display_name: '{"text":"Customizeable!","color":"gold"}', color: "yellow"}
data modify storage bossbar:api bossbar insert 13 value {display_name: '{"text":"Customizeable!","color":"gold"}', color: "yellow"}
data modify storage bossbar:api bossbar insert 14 value {display_name: '{"text":"Change the time between frames!","color":"dark_blue"}', display_time: 100, color: "blue"}
data modify storage bossbar:api bossbar insert 15 value {display_name: '{"text":"Change the time between frames!","color":"dark_blue"}', display_time: 100, color: "blue"}
data modify storage bossbar:api bossbar insert 16 value {display_name: '{"text":"Show the percent!","color":"dark_green"}', display_percent: true, color: "green"}
data modify storage bossbar:api bossbar insert 17 value {display_name: '{"text":"Show the percent!","color":"dark_green"}', display_percent: true, color: "green"}
data modify storage bossbar:api bossbar insert 18 value {display_name: '{"text":"Whats a parent?","color":"red"}', color: "pink"}
data modify storage bossbar:api bossbar insert 19 value {display_name: '{"text":"Whats a parent?","color":"red"}', color: "pink"}

color

Allowed strings for color

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

display_percent

Allowed types for display_percent

  • true - Will display the percent on the left.
  • false - (default) Will not display the percent.
  • left - Will display the percent on the left.
  • right - Will display the percent on the right.

style

Allowed string for style

  • progress - (default) Not notched
  • notched_10 - 10 notches
  • notched_12 - 12 notches
  • notched_20 - 20 notches
  • notched_6 - 6 notches

value

Allowed strings for value

  • 0-100- (default: 0) The amount to fill the bossbar
  • random - Will choose a random number from 0-100
  • auto - Will choose the number depending on how many items you have (100 / totalFrames * currentFrame = value)
Clone this wiki locally