# 🔣 Placeholders

It allows NexusProxy to replace supported placeholders inside proxy messages and provides a command to test placeholder output directly from the proxy.

{% hint style="warning" %}
This module is not the same as the PlaceholderAPI expansion.

The Placeholders module works inside the Velocity proxy.

The PlaceholderAPI expansion is installed separately on backend Paper, Spigot, or Purpur servers.
{% endhint %}

***

### What It Does

The Placeholders module adds proxy-side placeholder support for NexusProxy messages and systems.

It can be used for:

* Testing placeholders from the proxy
* Replacing online count placeholders
* Replacing proxy count placeholders
* Replacing server count placeholders
* Replacing friends placeholders
* Replacing ping placeholders
* Formatting dynamic text in NexusProxy messages

***

### When To Enable It

Enable this module if you want to use NexusProxy placeholders inside proxy-side messages or test placeholder output directly from the proxy.

This module is useful if you use:

* Dynamic messages
* Online count placeholders
* Friends placeholders
* Ping placeholders
* Proxy-side announcements
* Proxy-side formatted text

***

### Requirements

The Placeholders module can work without external dependencies.

However, some placeholders may require Redis or database storage depending on what data they need.

| Dependency     | Required    | Purpose                                                                   |
| -------------- | ----------- | ------------------------------------------------------------------------- |
| Redis          | Recommended | Used for global, proxy, and server online counts across multiple proxies. |
| MySQL          | Optional    | Used for friends-related data, depending on setup.                        |
| MongoDB        | Optional    | Used for friends-related data, depending on setup.                        |
| PacketEvents   | No          | Not required.                                                             |
| Discord        | No          | Not required.                                                             |
| PlaceholderAPI | No          | Not required for proxy-side placeholders.                                 |

{% hint style="info" %}
For accurate global online counts across multiple proxies, Redis is recommended.
{% endhint %}

***

### Configuration File

The Placeholders module configuration file is located at:

```
plugins/NexusProxy/modules/placeholders/placeholders.yml
```

This file can contain settings for:

* Module status
* Command names
* Command aliases
* Permissions
* Placeholder behavior
* Messages
* Formatting options

{% hint style="warning" %}
Command names and aliases may be configurable in the module file.

The commands shown here are the default commands.
{% endhint %}

***

### Default Commands

| Command                | Description                                   |
| ---------------------- | --------------------------------------------- |
| `/nplaceholder <text>` | Tests placeholder replacement from the proxy. |
| `/npapi <text>`        | Alias for the placeholder test command.       |

***

### Permissions

| Permission                        | Description                                      |
| --------------------------------- | ------------------------------------------------ |
| `nexusproxy.command.placeholders` | Allows usage of `/nplaceholder` and its aliases. |

***

### Recommended LuckPerms Setup

#### Admin

```
/lp group admin permission set nexusproxy.command.placeholders true
```

{% hint style="info" %}
This command is mainly useful for administrators testing placeholder output.
{% endhint %}

***

### Proxy-Side Placeholders

The following placeholders are available inside NexusProxy proxy-side systems.

***

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

Examples:

```
%global_online%
%proxy_online%
%server_lobby_online%
%proxy_Proxy-1_online%
```

{% hint style="warning" %}
For multi-proxy networks, Redis should be enabled for accurate global and proxy online counts.
{% 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.                  |

{% hint style="info" %}
Friends placeholders may require the Friends module and database storage depending on your setup.
{% 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 ping difference between the viewer and another player. |
| `%nexusproxy_difference_<player1>_<player2>%` | Shows ping difference between two players.                   |

Examples:

```
%nexusproxy_ping%
%nexusproxy_coloured_ping%
%nexusproxy_ping_Steve%
%nexusproxy_coloured_ping_Steve%
%nexusproxy_difference_Steve%
%nexusproxy_difference_Steve_Alex%
```

***

### Testing Placeholders

Use `/nplaceholder` to test placeholder replacement.

Example:

```
/nplaceholder Online: %global_online%
```

Alias:

```
/npapi Online: %global_online%
```

This is useful for checking whether a placeholder returns the expected value before using it in a message, announcement, or configuration file.

***

### Placeholders Module vs PlaceholderAPI Expansion

NexusProxy has two different placeholder systems.

| System                   | Where It Runs                      | Purpose                                                                         |
| ------------------------ | ---------------------------------- | ------------------------------------------------------------------------------- |
| Placeholders module      | Velocity proxy                     | Used inside NexusProxy proxy-side messages and systems.                         |
| PlaceholderAPI expansion | Backend Paper/Spigot/Purpur server | Used by backend plugins such as scoreboards, tab plugins, menus, and holograms. |

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

The expansion belongs in the backend server's PlaceholderAPI expansions folder.
{% endhint %}

***

### PlaceholderAPI Expansion Location

If you want NexusProxy placeholders in backend plugins, install the expansion here:

```
plugins/PlaceholderAPI/expansions/expansion-nexusproxy.jar
```

The expansion configuration is located at:

```
plugins/PlaceholderAPI/expansions/NexusProxy/config.yml
```

{% hint style="info" %}
The PlaceholderAPI expansion has its own documentation page in the Placeholder Systems section.
{% endhint %}

***

### Common Use Cases

#### Test global online count

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

***

#### Test server online count

```
/nplaceholder Lobby online: %server_lobby_online%
```

***

#### Test proxy online count

```
/nplaceholder Proxy online: %proxy_online%
```

***

#### Test ping

```
/nplaceholder Your ping: %nexusproxy_ping%
```

***

#### Test colored ping

```
/nplaceholder Ping: %nexusproxy_coloured_ping%
```

***

### Setup Tips

* Use `/nplaceholder` to test placeholders before using them in configs.
* Enable Redis for accurate global online counts in multi-proxy setups.
* Use database storage if friends placeholders need persistent friend data.
* Make sure proxy IDs match your `cluster.proxy_id` values when using proxy placeholders.
* Make sure server names match your Velocity backend server names when using server placeholders.
* Do not confuse proxy-side placeholders with PlaceholderAPI backend placeholders.

***

### Common Issues

#### Placeholder returns 0

Check that:

* The Placeholders module is enabled.
* Redis is enabled if the placeholder needs cross-proxy data.
* The server name is correct.
* The proxy ID is correct.
* The required module is enabled.
* Database storage is configured if the placeholder needs persistent data.

***

#### Global online count is wrong

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 is correct.
* The server name matches Velocity exactly.
* Redis is enabled if using multi-proxy data.
* Players are actually connected to that backend server.

***

#### Proxy online placeholder returns 0

Check that:

* The proxy ID is correct.
* The proxy ID matches `cluster.proxy_id`.
* Redis is enabled and connected.
* The target proxy is online and publishing presence data.

***

#### `/nplaceholder` does not work

Check that:

* The Placeholders module is enabled.
* The player has `nexusproxy.command.placeholders`.
* The command was not renamed in `placeholders.yml`.
* Another plugin is not overriding the command.

***

### Summary

The Placeholders module provides proxy-side placeholder parsing for NexusProxy.

It is useful for testing and using dynamic values such as online counts, friends data, and ping information inside NexusProxy systems.


---

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