-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.7.3 - Placeholders Replacements & 1.21.4 (#236)
* Added PlaceholderReplacements * Removed server display names * Fixed disconnect problem * Added support for 1.21.4
- Loading branch information
Showing
17 changed files
with
259 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
Velocitab supports placeholder replacements, which allow you to replace a placeholder with a different value. This is useful for things like changing the text of a date placeholder to a localized version, changing the text of a biome placeholder to a color or you can use a vanish placeholder to show a player's vanish status if the placeholder returns just a boolean (true/false). | ||
|
||
|
||
## Configuring | ||
|
||
Placeholder replacements are configured in the `placeholder_replaments` section of the every Tab Group. | ||
You can specify a list of replacements for a placeholder, and the replacements will be applied in the order they are listed. | ||
|
||
The replacements are specified as a list of objects with two properties: `placeholder` and `replacement`. | ||
`placeholder` is the placeholder to replace, and `replacement` is the replacement text. | ||
|
||
### Example section | ||
```yaml | ||
placeholder_replaments: | ||
'%current_date_weekday_en-US%': | ||
- placeholder: Monday | ||
replacement: <red>Monday</red> | ||
- placeholder: Tuesday | ||
replacement: <gold>Tuesday</gold> | ||
- placeholder: Else | ||
replacement: <green>Other day</green> | ||
'%player_world_type%': | ||
- placeholder: Overworld | ||
replacement: '<aqua>Overworld</aqua>' | ||
- placeholder: Nether | ||
replacement: '<red>Nether</red>' | ||
- placeholder: End | ||
replacement: '<yellow>End</yellow>' | ||
'%player_biome%': | ||
- placeholder: PLAINS | ||
replacement: <red>Plains</red> | ||
- placeholder: DESERT | ||
replacement: <yellow>Desert</yellow> | ||
- placeholder: RIVER | ||
replacement: <aqua>River</aqua> | ||
``` | ||
## Specified cases | ||
### Vanish status | ||
If you want to show a player's vanish status, for example, you can use the `%advancedvanish_is_vanished%` placeholder. | ||
This placeholder returns a boolean value, so you can use it to show a player's vanish status. | ||
|
||
For example, if you wanted to show a player's vanish status as a color, you could use the following replacements: | ||
```yaml | ||
placeholder_replaments: | ||
'%advancedvanish_is_vanished%': | ||
- placeholder: Yes | ||
replacement: <red>Vanished</red> | ||
- placeholder: No | ||
replacement: <green>Not vanished</green> | ||
``` | ||
|
||
### Else clause | ||
If you don't want to specify every possible value for a placeholder, you can use the `ELSE` placeholder. | ||
This placeholder will be replaced with the replacement text of the first replacement that doesn't have a placeholder. | ||
|
||
For example, if you wanted to show the current date as a color, you could use the following replacements: | ||
```yaml | ||
placeholder_replaments: | ||
'%current_date_weekday_en-US%': | ||
- placeholder: Monday | ||
replacement: <red>Monday</red> | ||
- placeholder: Tuesday | ||
replacement: <gold>Tuesday</gold> | ||
- placeholder: ELSE | ||
replacement: <green>Other day</green> | ||
``` | ||
|
||
### Placeholder not present in a server | ||
If you have a group with multiple servers, and you have a placeholder that is not present in one of the servers, you can use the `%<placeholder>%` as a placeholder it will handle the case where the placeholder is not present in the server. | ||
|
||
```yaml | ||
placeholder_replaments: | ||
'%huskhomes_homes_count%': | ||
- placeholder: '%huskhomes_homes_count%' | ||
replacement: <red>No homes in this server</red> | ||
``` | ||
|
||
If you want you can also set the replacement as an empty string, which will be replaced with the empty string. | ||
|
||
```yaml | ||
placeholder_replaments: | ||
'%huskhomes_homes_count%': | ||
- placeholder: '%huskhomes_homes_count%' | ||
replacement: '' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/net/william278/velocitab/config/PlaceholderReplacement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* This file is part of Velocitab, licensed under the Apache License 2.0. | ||
* | ||
* Copyright (c) William278 <[email protected]> | ||
* Copyright (c) contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.william278.velocitab.config; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public record PlaceholderReplacement(@NotNull String placeholder, @NotNull String replacement) { | ||
} |
Oops, something went wrong.