# 🧬 Proxy-side Placeholders

These placeholders are used inside NexusProxy messages, formats, announcements, and other proxy-side systems.

{% hint style="warning" %}
Proxy-side placeholders are not the same as PlaceholderAPI placeholders.

Proxy-side placeholders work inside the Velocity proxy.

PlaceholderAPI placeholders require the separate NexusProxy PlaceholderAPI expansion installed on backend servers.
{% endhint %}

***

### What Are Proxy-side Placeholders?

Proxy-side placeholders are dynamic values replaced by NexusProxy inside its own systems.

They can be used to show information such as:

* Global online players
* Proxy online players
* Backend server online players
* Friends count
* Online friends
* Offline friends
* Friend limits
* Player ping
* Colored ping
* Ping differences

***

### Requirements

Some placeholders work without external dependencies.

Other placeholders need Redis, database storage, or specific NexusProxy modules.

| Placeholder Type           | Recommended / Required Setup                                                |
| -------------------------- | --------------------------------------------------------------------------- |
| Global online placeholders | Redis recommended for multi-proxy networks.                                 |
| Proxy online placeholders  | Redis recommended for multi-proxy networks.                                 |
| Server online placeholders | Redis recommended for multi-proxy networks.                                 |
| Friends placeholders       | Friends module + database recommended. Redis recommended for online status. |
| Ping placeholders          | Ping module recommended.                                                    |
| Colored ping placeholders  | Ping module recommended.                                                    |

***

### Testing Placeholders

You can test proxy-side placeholders with:

```
/nplaceholder <text>
```

Alias:

```
/npapi <text>
```

Example:

```
/nplaceholder Network online: %global_online%
```

Required permission:

```
nexusproxy.command.placeholders
```

***

### Online Count Placeholders

| Placeholder                | Description                                                  |
| -------------------------- | ------------------------------------------------------------ |
| `%global_online%`          | Shows the global online player count known by NexusProxy.    |
| `%proxy_online%`           | Shows the online player count for the current proxy.         |
| `%server_<server>_online%` | Shows the online player count for a specific backend server. |
| `%proxy_<proxy>_online%`   | Shows the online player count for a specific proxy ID.       |

***

### Online Count Examples

#### Global online

```
%global_online%
```

Example usage:

```
There are %global_online% players online.
```

***

#### Current proxy online

```
%proxy_online%
```

Example usage:

```
This proxy has %proxy_online% players online.
```

***

#### Backend server online

```
%server_<server>_online%
```

Example:

```
%server_lobby_online%
```

Example usage:

```
Lobby players: %server_lobby_online%
```

{% hint style="warning" %}
The server name must match the backend server name configured in Velocity.
{% endhint %}

***

#### Specific proxy online

```
%proxy_<proxy>_online%
```

Example:

```
%proxy_Proxy-1_online%
```

Example usage:

```
Proxy-1 players: %proxy_Proxy-1_online%
```

{% hint style="warning" %}
The proxy name must match the `cluster.proxy_id` configured in `nexusproxy.yml`.
{% endhint %}

***

### Friends Placeholders

| Placeholder         | Description                                       |
| ------------------- | ------------------------------------------------- |
| `%friends_total%`   | Shows the player's total number of friends.       |
| `%friends_online%`  | Shows the player's online friends count.          |
| `%friends_offline%` | Shows the player's offline friends count.         |
| `%friends_pending%` | Shows the player's pending friend requests count. |
| `%friends_limit%`   | Shows the player's friend limit.                  |

***

### Friends Placeholder Examples

#### Total friends

```
%friends_total%
```

Example usage:

```
Friends: %friends_total%
```

***

#### Online friends

```
%friends_online%
```

Example usage:

```
Online friends: %friends_online%
```

***

#### Offline friends

```
%friends_offline%
```

Example usage:

```
Offline friends: %friends_offline%
```

***

#### Pending friend requests

```
%friends_pending%
```

Example usage:

```
Pending requests: %friends_pending%
```

***

#### Friend limit

```
%friends_limit%
```

Example usage:

```
Friend limit: %friends_total%/%friends_limit%
```

{% hint style="info" %}
Friends placeholders work best when the Friends module is enabled and database storage is configured.
{% endhint %}

***

### Ping Placeholders

| Placeholder                                   | Description                                                      |
| --------------------------------------------- | ---------------------------------------------------------------- |
| `%nexusproxy_ping%`                           | Shows the player's ping.                                         |
| `%nexusproxy_coloured_ping%`                  | Shows the player's ping with color formatting.                   |
| `%nexusproxy_ping_<player>%`                  | Shows another player's ping.                                     |
| `%nexusproxy_coloured_ping_<player>%`         | Shows another player's ping with color formatting.               |
| `%nexusproxy_difference_<player>%`            | Shows the ping difference between the viewer and another player. |
| `%nexusproxy_difference_<player1>_<player2>%` | Shows the ping difference between two players.                   |

***

### Ping Placeholder Examples

#### Own ping

```
%nexusproxy_ping%
```

Example usage:

```
Your ping is %nexusproxy_ping%ms.
```

***

#### Own colored ping

```
%nexusproxy_coloured_ping%
```

Example usage:

```
Ping: %nexusproxy_coloured_ping%
```

***

#### Another player's ping

```
%nexusproxy_ping_<player>%
```

Example:

```
%nexusproxy_ping_Steve%
```

***

#### Another player's colored ping

```
%nexusproxy_coloured_ping_<player>%
```

Example:

```
%nexusproxy_coloured_ping_Steve%
```

***

#### Ping difference with another player

```
%nexusproxy_difference_<player>%
```

Example:

```
%nexusproxy_difference_Steve%
```

***

#### Ping difference between two players

```
%nexusproxy_difference_<player1>_<player2>%
```

Example:

```
%nexusproxy_difference_Steve_Alex%
```

***

### Redis and Online Placeholders

Redis is recommended for accurate online placeholders in multi-proxy networks.

Redis helps NexusProxy share presence data between proxies.

Use Redis for:

* `%global_online%`
* `%proxy_online%`
* `%server_<server>_online%`
* `%proxy_<proxy>_online%`
* Friends online status

{% hint style="warning" %}
If Redis is disabled on a multi-proxy network, global online counts and cross-proxy presence may be incomplete or incorrect.
{% endhint %}

***

### Database and Friends Placeholders

Database storage is recommended for friends placeholders.

MySQL or MongoDB can store persistent friend data.

Use database storage for:

* `%friends_total%`
* `%friends_online%`
* `%friends_offline%`
* `%friends_pending%`
* `%friends_limit%`

{% hint style="info" %}
Redis handles online friend presence.

The database stores persistent friend relationships and friend-related data.
{% endhint %}

***

### Proxy-side vs PlaceholderAPI Expansion

NexusProxy has two different placeholder systems.

| System                   | Where It Runs                       | Used For                                                             |
| ------------------------ | ----------------------------------- | -------------------------------------------------------------------- |
| Proxy-side placeholders  | Velocity proxy                      | NexusProxy messages, announcements, formats, and proxy-side systems. |
| PlaceholderAPI expansion | Backend Paper/Spigot/Purpur servers | Backend plugins such as scoreboards, tabs, menus, and holograms.     |

{% hint style="danger" %}
Do not install the PlaceholderAPI expansion jar inside the Velocity plugins folder.

It must be installed on backend servers inside the PlaceholderAPI expansions folder.
{% endhint %}

***

### Example Uses

#### Announcement message

```yaml
messages:
  - "&6Network &8» &fThere are &e%global_online% &fplayers online."
```

***

#### Lobby message

```yaml
messages:
  - "&aLobby players: &f%server_lobby_online%"
```

***

#### Friends message

```yaml
messages:
  - "&bFriends: &f%friends_online%&7/&f%friends_total%"
```

***

#### Ping message

```yaml
messages:
  - "&aYour ping: &f%nexusproxy_coloured_ping%"
```

***

### Common Issues

#### Placeholder returns 0

Check that:

* The required module is enabled.
* Redis is enabled if the placeholder needs cross-proxy data.
* Database storage is enabled if the placeholder needs persistent friends data.
* The server name is correct.
* The proxy ID is correct.
* NexusProxy was restarted or reloaded after configuration changes.

***

#### Global online count is incorrect

Check that:

* Redis is enabled on every proxy.
* Every proxy uses the same Redis settings.
* Every proxy uses the same `channel_prefix`.
* Every proxy has a unique `cluster.proxy_id`.
* `/nexusproxy storage` shows Redis as connected.

***

#### Server online placeholder returns 0

Check that:

* The backend server name matches Velocity exactly.
* Players are actually connected to that backend server.
* Redis is enabled if using multi-proxy presence.
* The placeholder is typed correctly.

***

#### Proxy online placeholder returns 0

Check that:

* The proxy ID matches `cluster.proxy_id`.
* Redis is enabled.
* The target proxy is online.
* The target proxy is connected to the same Redis instance.
* The `channel_prefix` matches.

***

#### Friends placeholders return 0

Check that:

* The Friends module is enabled.
* Database storage is enabled.
* Friend data exists.
* Redis is enabled if online friend status is needed.
* The player actually has friends.
* `/nexusproxy storage` shows the database and Redis as connected.

***

#### Ping placeholders do not work

Check that:

* The Ping module is enabled.
* The placeholder is typed correctly.
* The target player is online if using another-player ping placeholders.
* The Placeholders module is enabled if testing with `/nplaceholder`.

***

### Setup Tips

* Use `/nplaceholder` to test placeholders before adding them to public messages.
* Use Redis for multi-proxy online counts.
* Use database storage for friends placeholders.
* Make sure server names match Velocity.
* Make sure proxy placeholders use the correct `cluster.proxy_id`.
* Keep placeholder text readable.
* Do not confuse proxy-side placeholders with PlaceholderAPI backend placeholders.

***

### Summary

Proxy-side placeholders are used inside NexusProxy systems on the Velocity proxy.

They are useful for dynamic messages, online counts, friends information, ping display, announcements, and other proxy-side features.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nexusproxy.nemesismc.net/proxy-side-placeholders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
