Skip to content

Scoreboard API

MattMX edited this page Jul 4, 2024 · 8 revisions

Creating a static scoreboard

Start off by calling scoreboard(title)

val scoreboard = scoreboard(!"Title")

This will create a usable scoreboard with the title of Title.

Adding lines

val scoreboard = scoreboard(!"&a&lTitle") {
    add(!"&fThis is a line")
    add(!" ")
    add(!"&fThis is another line")
}

Remember that scoreboards can only have 16 lines

You can then display the scoreboard to a player like so.

scoreboard.showFor(player)

Creating an dynamic scoreboard

Currently only available on dev branch!

val scoreboard = dynamicScoreboard(!"&dYour Title") {

    var t = false
    val line = scoreboardLine {
        t = !t
        !"${if (t) "&c" else "&7"}&m                      "
    }

    +line
    +!"&fStatic line"
    +{ !"&fServer Time: ${Date()}" } updateEvery 20L // every 1s
    +line
}

If you wish to update manually you can also call scoreboard[index] = !"Some other component" which will update for all players live.

Clone this wiki locally