Simple sidebar helper

Sidebar

Sidebar is a high-level helper that wraps Scoreboard and Objective to make creating sidebar displays simple. It handles score ordering and line management automatically.


Constants

MAX_LINES

Sidebar.MAX_LINES  # 15

Maximum number of lines a sidebar can display (Minecraft limitation).


Constructor

Sidebar(title="")

Create a new sidebar.

sidebar = Sidebar("§6§lMy Server")

Attributes

title

The sidebar title.


Item Access

Sidebar supports index-based access using [] notation. Slot 0 is the bottom line, higher slots are higher lines.

Set a line

sidebar[slot] = text

Get a line

text = sidebar[slot]

Delete a line

del sidebar[slot]

Removes the line at the given slot.


Methods

show

sidebar.show(player)

Display this sidebar to a player. This is synchronous — it assigns a scoreboard to the player.


Example: Server info sidebar

from bridge import *

sidebar = Sidebar("§6§lMy Server")
sidebar[6] = "§7──────────"
sidebar[5] = "§fOnline: §a0"
sidebar[4] = "§fTPS: §a20.0"
sidebar[3] = ""
sidebar[2] = "§fKills: §c0"
sidebar[1] = "§fDeaths: §c0"
sidebar[0] = "§7──────────"

@event
async def player_join(e: Event):
    sidebar[5] = f"§fOnline: §a{len(server.players)}"
    sidebar.show(e.player)

@event
async def player_quit(e: Event):
    sidebar[5] = f"§fOnline: §a{len(server.players) - 1}"

Example: Per-player stats

from bridge import *

kills = {}

@event
async def player_join(e: Event):
    p = e.player
    kills.setdefault(p.name, 0)
    sb = Sidebar("§c§lPvP Stats")
    sb[3] = f"§fPlayer: §a{p.name}"
    sb[2] = f"§fKills: §e{kills[p.name]}"
    sb[1] = f"§fHealth: §c{int(p.health)}❤"
    sb[0] = "§7play.example.com"
    sb.show(p)

Note: Sidebar creates its own internal scoreboard and objective. If you need multiple objectives or teams, use the lower-level Scoreboard API.