Global server API

Server

The server object is a module-level global available in every script. It provides access to players, worlds, boss bars, and server-wide operations.

from bridge import *
# `server` is available immediately
players = server.players

Attributes

players

All currently online players. This is a snapshot — the list is re-fetched each time you access it.

for p in server.players:
    await p.send_message("Hello everyone!")

worlds

All loaded worlds.

name

The server name as configured in server.properties.

version

The full server version string (e.g. "git-Paper-123 (MC: 1.21.4)").

motd

The server's Message of the Day.

max_players

Maximum number of players allowed.

tps

Server TPS (ticks per second) values. Typically contains 1-minute, 5-minute, and 15-minute averages. A healthy server runs at 20 TPS.

mspt

Milliseconds per tick. Lower is better. At 20 TPS, this should be ≤ 50ms.

last_tick_time

Duration of the last tick in milliseconds.

queue_len

Number of tasks currently in the main thread queue.

boss_bars

All active boss bars on the server.

plugin_manager

The Bukkit plugin manager. Primarily useful for advanced reflection use cases.

scheduler

The Bukkit scheduler. Rarely needed — use server.after() and @task instead.

scoreboard_manager

The server's scoreboard manager.


Methods

broadcast

await server.broadcast(message: str)

Broadcast a message to all online players and the server console.

await server.broadcast("§a[Server]§r Restarting in 10 seconds!")

execute

result = await server.execute(command: str)

Execute a command as the server console. This runs with full server permissions.

await server.execute("weather clear")
await server.execute("give Steve diamond 64")

world

w = await server.world(name: str)

Get a world by name.

nether = await server.world("world_nether")

create_boss_bar

bar = await server.create_boss_bar(title: str, color: BarColor, style: BarStyle)

Create a new boss bar.

bar = await server.create_boss_bar("Event Timer", BarColor.RED, BarStyle.SEGMENTED_6)

get_advancement

adv = await server.get_advancement(key: str)

Get an advancement by its namespaced key.

after

await server.after(ticks: int = 1, after: callable | None = None)

Pause execution for a number of ticks. Optionally run a callback after the wait.

await server.after(20)  # Wait 1 second
await server.after(60)  # Wait 3 seconds

# With callback
await server.after(20, after=lambda: print("Done waiting!"))

frame

async with server.frame():
    await player.send_message("Line 1")
    await player.send_message("Line 2")

Async context manager that batches multiple bridge calls into a single network send. Useful for reducing round-trips when making many calls at once.

atomic

async with server.atomic():
    await player.set_health(20)
    await player.set_food_level(20)

Async context manager that batches calls as an atomic group. All calls succeed or fail together.

flush

await server.flush()

Send all pending batched requests immediately. Use this inside a frame() or atomic() block if you need partial results before the block ends.