Conditional Placeholders can now be used in headers and footers
Some checks failed
CI Tests & Publish / build (push) Failing after 2m13s
Update Docs / deploy-wiki (push) Failing after 27s

Updated docs
This commit is contained in:
AlexDev_ 2025-08-03 11:08:32 +02:00
parent beed377676
commit 973af9c62a
4 changed files with 32 additions and 5 deletions

View File

@ -1,8 +1,6 @@
Conditional placeholders allow you to display different values based on certain conditions. The format Conditional placeholders allow you to display different values based on certain conditions. The format
is `<velocitab_condition|<condition>|<true>|<false>>` and the relational format is `<velocitab_rel_condition|<condition>|<true>|<false>>`. is `<velocitab_condition|<condition>|<true>|<false>>` and the relational format is `<velocitab_rel_condition|<condition>|<true>|<false>>`.
Currently, this system is only available for the `format` and `nametag` fields in the tab groups configuration.
**Note:** The difference between the two is that relational placeholders are evaluated from the viewer's perspective, while the conditional placeholders are evaluated from the player's perspective. **Note:** The difference between the two is that relational placeholders are evaluated from the viewer's perspective, while the conditional placeholders are evaluated from the player's perspective.
So if you have 200 players, if you use a conditional placeholder, the placeholder will be evaluated 200 times, while if you use a relational placeholder, it will be evaluated 200*200 = 40000 times. So if you have 200 players, if you use a conditional placeholder, the placeholder will be evaluated 200 times, while if you use a relational placeholder, it will be evaluated 200*200 = 40000 times.
Using relational placeholders could be really slow, so it is recommended to not use them unless you need them. Using relational placeholders could be really slow, so it is recommended to not use them unless you need them.

View File

@ -37,6 +37,18 @@ placeholder_replacements:
replacement: <aqua>River</aqua> replacement: <aqua>River</aqua>
``` ```
## Example for the server placeholder
```yaml
placeholder_replacements:
'%server%':
- placeholder: spawn
replacement: <bold><#ff8080>Spawn
- placeholder: realms
replacement: <bold><#ff0000>Realms
- placeholder: dungeons
replacement: <bold><#00ff00>Dungeons
```
## Specified cases ## Specified cases
### Vanish status ### Vanish status

View File

@ -54,3 +54,18 @@ PlaceholderAPI placeholders are cached to reduce plugin message traffic. By defa
## MiniPlaceholders support ## MiniPlaceholders support
If you are using MiniMessage [[Formatting]], you can use [MiniPlaceholders](https://github.com/MiniPlaceholders/MiniPlaceholders) with Velocitab for MiniMessage-styled component placeholders provided by other proxy plugins. Install MiniPlaceholders on your Velocity proxy, set the `formatter_type` to `MINIMESSAGE` and ensure `enable_miniplaceholders_hook` is set to `true` If you are using MiniMessage [[Formatting]], you can use [MiniPlaceholders](https://github.com/MiniPlaceholders/MiniPlaceholders) with Velocitab for MiniMessage-styled component placeholders provided by other proxy plugins. Install MiniPlaceholders on your Velocity proxy, set the `formatter_type` to `MINIMESSAGE` and ensure `enable_miniplaceholders_hook` is set to `true`
You can also use [Relational Placeholders](Relational-Placeholders). You can also use [Relational Placeholders](Relational-Placeholders).
## PLaceholders Replacements
Velocitab supports replacing placeholders values with other values.
```yaml
placeholder_replacements:
'%server%':
- placeholder: spawn
replacement: <bold><#ff8080>Spawn
- placeholder: realms
replacement: <bold><#ff0000>Realms
- placeholder: dungeons
replacement: <bold><#00ff00>Dungeons
```
See [[Placeholders-Replacements]] for more information.

View File

@ -652,16 +652,18 @@ public class PlayerTabList {
public Component getHeader(@NotNull TabPlayer player) { public Component getHeader(@NotNull TabPlayer player) {
final String header = player.getGroup().getHeader(player.getHeaderIndex()); final String header = player.getGroup().getHeader(player.getHeaderIndex());
final String replaced = plugin.getPlaceholderManager().applyPlaceholders(player, header); final String replaced = plugin.getPlaceholderManager().applyPlaceholders(player, header);
final String withVelocitabPlaceholders = plugin.getPlaceholderManager().formatVelocitabPlaceholders(replaced, player, null);
return plugin.getFormatter().format(replaced, player, plugin); return plugin.getFormatter().format(withVelocitabPlaceholders, player, plugin);
} }
// Get the component for the TAB list footer // Get the component for the TAB list footer
public Component getFooter(@NotNull TabPlayer player) { public Component getFooter(@NotNull TabPlayer player) {
final String footer = player.getGroup().getFooter(player.getFooterIndex()); final String footer = player.getGroup().getFooter(player.getFooterIndex());
final String replaced = plugin.getPlaceholderManager().applyPlaceholders(player, footer); final String replaced = plugin.getPlaceholderManager().applyPlaceholders(player, footer);
final String withVelocitabPlaceholders = plugin.getPlaceholderManager().formatVelocitabPlaceholders(replaced, player, null);
return plugin.getFormatter().format(replaced, player, plugin); return plugin.getFormatter().format(withVelocitabPlaceholders, player, plugin);
} }
/** /**