diff --git a/docs/Conditional-Placeholders.md b/docs/Conditional-Placeholders.md index 2285cd2..df0b914 100644 --- a/docs/Conditional-Placeholders.md +++ b/docs/Conditional-Placeholders.md @@ -1,8 +1,6 @@ Conditional placeholders allow you to display different values based on certain conditions. The format is `||>` and the relational format is `||>`. -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. 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. diff --git a/docs/Placeholders-Replacements.md b/docs/Placeholders-Replacements.md index e57a0fb..c69dd95 100644 --- a/docs/Placeholders-Replacements.md +++ b/docs/Placeholders-Replacements.md @@ -37,6 +37,18 @@ placeholder_replacements: replacement: River ``` +## Example for the server placeholder +```yaml + placeholder_replacements: + '%server%': + - placeholder: spawn + replacement: <#ff8080>Spawn + - placeholder: realms + replacement: <#ff0000>Realms + - placeholder: dungeons + replacement: <#00ff00>Dungeons +``` + ## Specified cases ### Vanish status diff --git a/docs/Placeholders.md b/docs/Placeholders.md index 950b5e1..d73e0c6 100644 --- a/docs/Placeholders.md +++ b/docs/Placeholders.md @@ -53,4 +53,19 @@ PlaceholderAPI placeholders are cached to reduce plugin message traffic. By defa ## 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` -You can also use [Relational Placeholders](Relational-Placeholders). \ No newline at end of file +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: <#ff8080>Spawn + - placeholder: realms + replacement: <#ff0000>Realms + - placeholder: dungeons + replacement: <#00ff00>Dungeons +``` + +See [[Placeholders-Replacements]] for more information. \ No newline at end of file diff --git a/src/main/java/net/william278/velocitab/tab/PlayerTabList.java b/src/main/java/net/william278/velocitab/tab/PlayerTabList.java index 2841702..95a3f2a 100644 --- a/src/main/java/net/william278/velocitab/tab/PlayerTabList.java +++ b/src/main/java/net/william278/velocitab/tab/PlayerTabList.java @@ -652,16 +652,18 @@ public class PlayerTabList { public Component getHeader(@NotNull TabPlayer player) { final String header = player.getGroup().getHeader(player.getHeaderIndex()); 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 public Component getFooter(@NotNull TabPlayer player) { final String footer = player.getGroup().getFooter(player.getFooterIndex()); 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); } /**