> ## Documentation Index
> Fetch the complete documentation index at: https://velas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Display a Per-Player Sidebar to Individual Players

> Create and display a PlayerSidebar bound to a single player, update its lines dynamically, and manage its full lifecycle using VelaBoard.

`PlayerSidebar` is bound to one player at a time and is the simplest way to show player-specific HUD data — things like score, level, or location that differ between players.

## Complete setup flow

<Steps>
  <Step title="Get the scoreboard handler">
    Obtain the `ScoreboardHandler` from the API entry point.

    ```java theme={null}
    ScoreboardHandler handler = ScoreboardAPI.getHandler();
    ```
  </Step>

  <Step title="Create a scoreboard">
    Create a `Scoreboard` instance through the handler.

    ```java theme={null}
    Scoreboard board = handler.createScoreboard();
    ```
  </Step>

  <Step title="Register the player">
    Add the player to the scoreboard before creating any sidebars for them.

    ```java theme={null}
    board.addPlayer(player);
    ```
  </Step>

  <Step title="Create the sidebar with a title">
    Create a `PlayerSidebar` with a display title.

    ```java theme={null}
    PlayerSidebar sidebar = board.createPlayerSidebar("§6§lMy Plugin");
    ```
  </Step>

  <Step title="Set lines">
    Populate the sidebar lines. Line `0` is the top line.

    ```java theme={null}
    sidebar.setLine(0, "§7Player: §f" + player.getName());
    sidebar.setLine(1, "§7Score: §f0");
    sidebar.setLine(2, "§7Level: §f1");
    ```
  </Step>

  <Step title="Assign the player">
    Bind the sidebar to the player using `setPlayer`.

    ```java theme={null}
    sidebar.setPlayer(player);
    ```
  </Step>

  <Step title="Show the sidebar">
    Call `show()` to display the sidebar to the player.

    ```java theme={null}
    sidebar.show();
    ```
  </Step>
</Steps>

### Full example

```java theme={null}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    ScoreboardHandler handler = ScoreboardAPI.getHandler();
    Scoreboard board = handler.createScoreboard();
    board.addPlayer(player);

    PlayerSidebar sidebar = board.createPlayerSidebar("§6§lMy Plugin");
    sidebar.setLine(0, "§7Player: §f" + player.getName());
    sidebar.setLine(1, "§7Score: §f0");
    sidebar.setLine(2, "§7Level: §f1");
    sidebar.setPlayer(player);
    sidebar.show();
}
```

## Updating lines dynamically

Call `setLine` with a new value to update a line's content. If you need the change to be visible immediately, call `show()` again after updating.

```java theme={null}
// Inside a repeating task or event handler
sidebar.setLine(1, "§7Score: §f" + getScore(player));
sidebar.setLine(2, "§7Level: §f" + getLevel(player));
sidebar.show();
```

<Tip>
  You only need to call `show()` after `setLine` if the sidebar is already visible and you want the update to take effect immediately. A single `show()` at setup time is sufficient if lines won't change.
</Tip>

## Hiding and removing

Use `hide()` to temporarily hide the sidebar without destroying it. You can call `show()` again later to bring it back.

```java theme={null}
sidebar.hide();

// Bring it back later
sidebar.show();
```

When you no longer need the sidebar, call `remove()` to destroy it and free its resources.

```java theme={null}
sidebar.remove();
```

## Checking state

VelaBoard provides several methods to inspect the current state of a `PlayerSidebar`:

| Method              | Description                                                       |
| ------------------- | ----------------------------------------------------------------- |
| `isBeingViewed()`   | Returns `true` if the sidebar is currently visible to the player. |
| `isRemoved()`       | Returns `true` if the sidebar has been destroyed with `remove()`. |
| `hasPlayer(Player)` | Returns `true` if the given player is assigned to this sidebar.   |
| `getPlayer()`       | Returns the `Player` currently assigned to this sidebar.          |

```java theme={null}
if (sidebar.isBeingViewed()) {
    // sidebar is actively visible
}

if (!sidebar.isRemoved()) {
    sidebar.setLine(0, "§7Updated value");
    sidebar.show();
}

Player assigned = sidebar.getPlayer();
```

<Note>
  A player can only have one sidebar visible at a time. Calling `show()` on a new sidebar automatically replaces the one they are currently viewing.
</Note>
