> ## 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.

# VelaBoard Bukkit Events: SidebarShow and TeamMember

> Reference for SidebarShowEvent and AddMemberToTeamEvent — two cancellable Bukkit events that let your plugin intercept and control scoreboard behavior.

VelaBoard fires two cancellable Bukkit events — `SidebarShowEvent` and `AddMemberToTeamEvent` — giving your plugin fine-grained control over scoreboard behavior.

<Note>Both events extend `org.bukkit.event.Event` and implement `Cancellable`. Register listeners the standard Bukkit way.</Note>

## SidebarShowEvent

**Package:** `org.velas.scoreboard.api.event`

Fired when a sidebar is about to be displayed to a player. Cancellable.

| Method                  | Returns                   | Description                                |
| ----------------------- | ------------------------- | ------------------------------------------ |
| `getPlayer()`           | `Player`                  | The player the sidebar is being shown to   |
| `getSidebar()`          | `Sidebar`                 | The sidebar being displayed                |
| `getReason()`           | `SidebarShowEvent.Reason` | Why the sidebar is being shown             |
| `isCancelled()`         | `boolean`                 | Whether the event is cancelled             |
| `setCancelled(boolean)` | `void`                    | Cancel to prevent the sidebar from showing |

### SidebarShowEvent.Reason enum

| Value         | Description                                |
| ------------- | ------------------------------------------ |
| `PLAYER_JOIN` | Sidebar shown automatically on player join |
| `MANUALLY`    | Sidebar shown via explicit `show()` call   |
| `OTHER`       | Other reason                               |

```java theme={null}
@EventHandler
public void onSidebarShow(SidebarShowEvent event) {
    // Block sidebar display for players without permission
    if (!event.getPlayer().hasPermission("myplugin.sidebar.view")) {
        event.setCancelled(true);
        return;
    }
    // Log when sidebars are manually shown
    if (event.getReason() == SidebarShowEvent.Reason.MANUALLY) {
        getLogger().info("Sidebar manually shown to " + event.getPlayer().getName());
    }
}
```

<Tip>Use `event.getSidebar().isPlayerSidebar()` or `isSharedSidebar()` to distinguish sidebar types inside `SidebarShowEvent`.</Tip>

***

## AddMemberToTeamEvent

**Package:** `org.velas.scoreboard.api.event`

Fired when a player or entity is about to be added to a team. Cancellable.

| Method                  | Returns                       | Description                                   |
| ----------------------- | ----------------------------- | --------------------------------------------- |
| `getUniqueIdOfMember()` | `UUID`                        | UUID of the player or entity being added      |
| `getTeam()`             | `Team`                        | The team being joined                         |
| `getReason()`           | `AddMemberToTeamEvent.Reason` | Why the member is being added                 |
| `isCancelled()`         | `boolean`                     | Whether the event is cancelled                |
| `setCancelled(boolean)` | `void`                        | Cancel to prevent the member from being added |

### AddMemberToTeamEvent.Reason enum

| Value         | Description                               |
| ------------- | ----------------------------------------- |
| `PLAYER_JOIN` | Player added to team on server join       |
| `PLAYER_ADD`  | Player added via `team.addPlayer(Player)` |
| `ENTITY_ADD`  | Entity added via `team.addEntity(Entity)` |
| `OTHER`       | Other reason                              |

```java theme={null}
@EventHandler
public void onTeamAdd(AddMemberToTeamEvent event) {
    // Prevent programmatic additions to the "vip" team
    if ("vip".equals(event.getTeam().getName())
            && event.getReason() == AddMemberToTeamEvent.Reason.PLAYER_ADD) {
        // Only allow join-based additions
        event.setCancelled(true);
    }
}
```

<Note>Cancelling an event only prevents the current action — it does not remove the sidebar or team from existence.</Note>

***

## Registering your listener

```java theme={null}
public class MyPlugin extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onSidebarShow(SidebarShowEvent event) {
        // handle event
    }

    @EventHandler
    public void onTeamAdd(AddMemberToTeamEvent event) {
        // handle event
    }
}
```
