> For the complete documentation index, see [llms.txt](https://docs.nursultan.fun/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nursultan.fun/game-data/server-scoreboard-tab-list.md).

# Server, scoreboard, tab list

## Where am I connected

```kotlin
game.connected()             // there is a connection
game.inGame()                // the world is loaded and the player exists

val server = game.server()

server.name()
server.address()             // "mc.example.com:25565"
server.type()                // SINGLEPLAYER, LAN, REALM, MULTIPLAYER
server.protocolVersion()
server.pingMs()
server.tps()                 // how many ticks per second the server manages
```

`tps()` is measured from how often ticks arrive — useful for not hammering the server with actions while it lags.

You can disconnect from code:

```kotlin
if (player.health() < 4f) {
    game.disconnect()
}
```

## The side scoreboard

```kotlin
val board = game.server().scoreboard()

board.visible()
board.title()                // the header
board.lines()                // lines top to bottom
```

Often you only want to know which mode you are in:

```kotlin
if (board.contains("BedWars", "Bed Wars")) {
    // we are on bedwars
}
```

`contains` checks the title and the lines for any of the words you pass and does not care about case.

## The tab list

```kotlin
val tab = game.server().tabList()

tab.header()
tab.footer()
tab.players()                // every player in the tab list

tab.headerContains("anarchy")
tab.footerContains("season")
```

`players()` gives you full [player entities](/game-data/entities-and-filters.md), with ping and game mode.

## Screens

```kotlin
game.screenOpen()            // is any screen open
game.screenKind()            // NONE, INVENTORY, CREATIVE, CONTAINER, CHAT, OTHER
game.closeScreen()
```

Handy for staying out of the way while the player digs through a chest:

```kotlin
if (game.screenKind() == ScreenKind.CONTAINER) return@on
```

There is a screen-closed event too — `ScreenCloseEvent`.

## Detect the server once

There is no point checking the scoreboard every tick. Once per world is enough:

```kotlin
var bedwars = false

on<WorldLoadEvent> {
    afterTicks(40) {
        bedwars = game.server().scoreboard().contains("BedWars")
    }
}
```

The delay is there because the scoreboard does not arrive the instant the world loads.
