# Navigator and queue

Build the server selector and decide how players get to each server.

The navigator is the menu players open to pick a server. The queue decides when they actually get sent. They're separate modules, so you can run the navigator alone, the queue alone, or both.

## Before you start

Server switching goes through the proxy's plugin messaging channel.

- **BungeeCord**: nothing to change.
- **Velocity**: set `bungee-plugin-message-channel = true` in `velocity.toml`.

Server names in GlacierHub must match the names in your proxy config exactly.

## Adding a server to the menu

Each entry in `navigator.yml` is one item in the menu:

```yaml
gui:
  size: 54
  title: "&#A0B4C8&lServer Navigator"
  close-on-select: true
  items:
    survival:
      enabled: true
      slot: 20
      material: "DIAMOND"
      name: "&#A0B4C8&lSurvival"
      server: "Survival"
      permission: ""
      hide-without-permission: false
      lore:
        - "&#94A3B8Click to teleport to &#A0B4C8Survival"
      unavailable-lore:
        - "&#E2E8F0&l✖ &#A0B4C8This server is currently unavailable."
```

- `server` is the name from your proxy config.
- `permission` locks the entry. With `hide-without-permission: true`, players without it don't see the item at all.
- `unavailable-lore` is added under the normal lore when the entry has `enabled: false` or the player lacks its permission. GlacierHub doesn't ping servers, so it isn't shown for servers that are offline or full.
- `size` must be a multiple of 9. If it's missing, 54 is used.
- `general.worlds` and `general.excluded-worlds` limit which worlds get the compass. Leave them out for every world.

Run `/glacierhub reload navigator` to apply changes.

## How a click becomes a connection

Each entry can set `connect-mode`. Leave it out to get `AUTO`.

| `connect-mode` | What happens |
| --- | --- |
| `AUTO` | ajQueue if it's installed and `depends.ajqueue` is `true`, otherwise a direct connect |
| `DIRECT` | Always a direct connect through the proxy |
| `QUEUE` | GlacierHub's own queue. The server must be listed in `queue.yml` |

If ajQueue or the built-in queue can't take the player, they're told and sent directly instead. The built-in queue is never used unless an entry asks for it.

```yaml
    survival:
      server: "Survival"
      connect-mode: QUEUE
```

`connection.cooldown` (2s) stops a double click from sending a player twice.

## Setting up the queue

List each queued server with its player cap:

```yaml
general:
  poll-interval: 3s
  position-update-interval: 10s
  priority-permissions:
    "glacierhub.queue.priority.staff": 100
    "glacierhub.queue.priority.vip": 10

servers:
  survival:
    max-players: 100
    permission: ""
```

Every `poll-interval`, the queue asks the proxy how many players each server has and sends the next players while it's under `max-players`. A per-server `permission` limits who can join that queue. Players with a higher priority weight go first; equal weights keep join order. Give a rank priority by granting its permission, for example `glacierhub.queue.priority.vip`.

Players can manage their place with:

```text
/queue join survival
/queue leave
/queue list
```

## Showing queue position

With PlaceholderAPI, put the position on the scoreboard or in the action bar:

```yaml
lines:
  - "&#94A3B8Queue &#647F9C» &#E2E8F0%glacierhubqueue_position%/%glacierhubqueue_size%"
  - "&#94A3B8Server &#647F9C» &#E2E8F0%glacierhubqueue_server%"
```
