-
Notifications
You must be signed in to change notification settings - Fork 63
Placeholders
First let's answer what is a placeholder exactly since the official PlaceholderAPI plugin doesn't even have a technical definition for it. What does it mean?
A placeholder is a simple English word, however I'll stick to its Minecraft plugin definition. A placeholder is simply a text that gets replaced by another text in a message.
For example in this message Hi, my kingdom name is %kingdoms_name% the placeholder %kingdoms_name% gets replaced by the name of the player's kingdom. Now you might ask whose kingdom exactly? Well, it really depends, but generally it'd be the kingdom of the person who the message belongs to.
If we wanted a more technical definition of a placeholder, in its core placeholders are made out of 3 main components.
Format: %identifier_<name>%
- A placeholder is always surrounded by two percent sign. Anything between these percent signs including the percent signs themselves will be replaced by something else.
- The
identifierwhich is a name to group a list of placeholders together to prevent conflicts. The identifier is always similar to the plugin name. For this plugin, KingdomsX, it'skingdoms - The name of the placeholder which is separated by an underscore from the identifier.
Sometimes placeholder names are longer than just one word, like %kingdoms_nation_kingdoms% which are separated by underscores.
Almost all plugins that you use separate names with an underscore too.
Note that the only thing all placeholders have in common are these 3 things. Plugins can do whatever they want with the name part. For example kingdoms has a lot of syntactic features such as placeholder formats, modifiers, functions and etc.
What do placeholders do?
Almost 95% percent of the time placeholders only replace text with no side effects, but rarely they'll also have side effects.
Technically placeholders can do things ranging from replacing a simple text to crashing your system.
Who defines placeholders?
Placeholders are defined by plugins, their behavior is also defined by plugins.
What is PlaceholderAPI?
PlaceholderAPI is a Minecraft plugin that allows people to register and use placeholders.
One of the main benefits of this plugin is that it allows you to use placeholders from other plugins in other plugins. This is where the identifier part is important, to avoid placeholder conflicts since there are just so many plugins out there with their own placeholders.
Here's a list of placeholders that you can use.
There are two ways you can use placeholders defined by other plugins with this plugin. Some plugins like Kingdoms don't require any additional setup while other plugins have a separate package that PlaceholderAPI will download for you to use. For more information about downloading packages refer to Expansion Cloud guide.
PlaceholderAPI will not yell at your if it finds a placeholder that doesn't know how to translate, it instead leaves it be without replacing it at all. Kingdoms also does the same thing, however other plugins might now.
I've seen a lot of placeholders with one word before.
If you've seen placeholders like %player%, %amount% %max_amount% before, these are standalone placeholders provided by plugins themselves. PlaceholderAPI doesn't handle these placeholders. For example kingdoms has two universal standalone placeholders %player% and %displaynane%. The former just shows the player name and the later shows the player name including any rank (permission plugin) prefix/suffix.
Kingdoms supports its own placeholders without needing a placeholder plugin. It supports PlaceholderAPI & MVdWPlaceholderAPI. You don't need to download the expansion from Papi ecloud, they're internally implemented into the plugin. The plugin's internal placeholder system is much more optimized than any other placeholder plugin, so it's technically better if you don't install these plugins when you don't need to use them.
Some of these placeholders have a default value in special cases which is accessed from config.yml -> default-placeholders
For example %kingdoms_name% will return the default value of the player is not in a kingdom. Or %kingdoms_territory% will return the default value if the land is not owned by any kingdom.
Kingdoms has a very unique feature for showing numeric placeholders. These features can also be used via PlaceholderAPI.
Placeholder modifiers are a single word used after the placeholder id and before the placeholder name.
Format: %kingdoms_<modifier>_<placeholder>%
short A placeholder that is shortened with number suffixes for big numbers to fit in small messages.
fancy A placeholder that is formatted with the currency format ###.00.
roman A placeholder that is formatted as roman numerals.
These are only useful for very small numbers (1 to 4000) if they're used for lower or higher numbers the plugin will error.
%kingdoms_short_members% - %kingdoms_fancy_bank% - %kingdoms_roman_rank_priority%
| Value | Short | Fancy | Roman |
|---|---|---|---|
| 100 | 100 | 100 | C |
| 12330.34 | 12.3K | 12,330.34 | Error |
| 42345234 | 42.3M | 42,345,234 | Error |
Most placeholders will depend on a certain context to get their information from. For example %kingdoms_name% or %kingdoms_lore% will need you to be in a kingdom to get its name and lore, otherwise there is no kingdom to get its name or lore. For this reason, instead of having the plugin yell at you with a big error, the concept of default placeholders come into play.
If you don't have a kingdom, all the text (string) placeholder will output an empty text (no spaces) and all the number placeholders will give 0 with a few exceptions. These can be changed in config.yml placeholder section.
Normally when you use a placeholder like %kingdoms_name% you get the kingdom's name or an empty text if the player doesn't have a kingdom.
Now let's say you wanted to decorate this text and do something like [%kingdoms_name%] this looks great when the player has a kingdom, but it'll show [] for players with no kingdom.
To solve this issue placeholder formats are defined in config:
formats:
brackets:
normal: '[%]'
default: ''
parens:
normal: "(%)"
default: ''In order to use these you write %kingdoms_name@brackets% (with the format %placeholder@formatname%)
In above % is a shorthand for the current placeholder.
If you wanted to get the count of a specific type of structures in a land, normally you'd think that the placeholder would look something like %kingdoms_structures_powercell_count%, well that looks like a good guess, but the problem is that placeholders are predefined by the plugin itself. You can't make a new placeholder yourself and since you can make new structure styles yourself, it'd be very inefficient for the plugin to automatically create placeholders for each of these structures.
To solve this issue placeholder functions take some parameters and operate on that parameter instead.
Following our previous example %kingdoms_structures_powercell_count% is actually pretty close to the actual placeholder which is %kingdoms_structures:count style=powercell
This format might look very weird at first, but it's really easy to understand, so let's take a look at each part.
-
structuresis simply the placeholder name, just like all the other placeholders. -
:countis saying that perform thecountfunction (indicated by the colon:) for this placeholder. Note that thecountfunction is unique to this placeholder and you can't use it with all other placeholders. For example you can't say%kingdoms_members:count%because there's nothing to calculate.%kingdoms_members%placeholder itself returns the calculated result. -
style=powercellHerestyleis a parameter ofcountfunction and its value ispowercell(indicated by the equals sign=)
So the general format for placeholder functions is: %kingdoms_<placeholder>:<function> [parameters]%
Where parameters are zero or more <parameter name>=<parameter value> separated by commas.
Additionally instead of specifically writing the parameter name, you can separate them in the position they appear without the function name only if the placeholder has one function.
Format: %kingdoms_<placeholder> <parameters>%
= zero or more <parameter value> separated by commas.
E.g. %kingdoms_structures powercell% - %kingdoms_top 1 max_members%
How do I know the position these arguments appear in? Check the parameters in this guide!
| Placeholder | Description |
|---|---|
%kingdoms_chat_channel% |
Your current chat channel name. |
%kingdoms_joined% |
The time that you joined your kingdom. |
%kingdoms_resource_points% |
Your kingdom's resource points. |
%kingdoms_last_donation_time% |
Last time you donated resource points to your kingdom. This is changed by the option in config.yml -> resource-points -> last-donation-duration
|
%kingdoms_last_donation_amount% |
The total donations you made during your last donation time. |
%kingdoms_total_donations% |
Your total resource points donations to your kingdom. |
%kingdoms_tax% |
The amount of money you have to pay to your kingdom. |
%kingdoms_territory% |
The kingdom name of the current player land, otherwise the default value. |
%kingdoms_claims% |
Amount of claims the kingdom has. This number can be higher than %kingdoms_claims% in various situations. |
%kingdoms_max_claims% |
Maximum amount of claims a kingdom can have. |
%kingdoms_power% |
Your power amount. |
%kingdoms_rank_node% |
Your kingdom's rank node. |
%kingdoms_rank_name% |
Your kingdom's rank name. |
%kingdoms_rank_color% |
Your kingdom's rank color. |
%kingdoms_rank_symbol% |
Your kingdom's rank symbol. |
%kingdoms_rank_priority% |
Your kingdom's rank priority. 0 is king and the maximum number is the member rank. |
%kingdoms_rank_max_claims% |
Maximum amount of lands your rank can claim in your kingdom. |
%kingdoms_nation_rank_node% |
Your nation's rank node. |
%kingdoms_nation_rank_name% |
Your nation's rank name. |
%kingdoms_nation_rank_color% |
Your nation's rank color. |
%kingdoms_nation_rank_symbol% |
Your nation's rank symbol. |
%kingdoms_nation_rank_priority% |
Your nation's rank priority. 0 is king and the maximum number is the member rank. |
%kingdoms_map_width% |
Your /k map width which is customizable. |
%kingdoms_map_height% |
Your /k map height which is customizable. |
| Placeholder | Description |
|---|---|
%kingdoms_name% |
Your kingdom name. |
%kingdoms_lore% |
Your kingdom lore that can be set and removed using /k lore |
%kingdoms_tag% |
Your kingdom tag that can be set and removed using /k tag |
%kingdoms_top_position% |
Your kingdom's position in /k top leaderboard. |
%kingdoms_members% |
Your kingdom members count. |
%kingdoms_max_members% |
Your kingdom max members count. |
%kingdoms_online_members% |
Your kingdom online members count. |
%kingdoms_offline_members% |
Your kingdom offline members count. |
%kingdoms_flag% |
Kingdom flag URL for Dynmap. |
%kingdoms_color% |
Kingdom HTML hex color code. |
%kingdoms_king% |
Your kingdom king name. |
%kingdoms_might% |
Your kingdom might count. |
%kingdoms_since% |
The date your kingdom was created in year-month-day format. |
%kingdoms_home% |
Your kingdom home location. |
%kingdoms_nexus% |
Your kingdom nexus location. |
%kingdoms_lands% |
Your kingdom land count. |
%kingdoms_avg_lands_distance% |
The average distance of your lands from your nexus or home (in order or 0 if none is set) This placeholder is mostly useful for taxes. |
%kingdoms_kingdom_power% |
Your kingdom's total power. |
%kingdoms_max_lands% |
Kingdom max land count. |
%kingdoms_shield_since% |
Time that you activated your kingdom shield. |
%kingdoms_shield_time% |
Your kingdom shield duration. |
%kingdoms_shield_time_left% |
Kingdom shield time left. |
%kingdoms_bank% |
Kingdom bank money. |
%kingdoms_ranks% |
Kingdom rank count. |
%kingdoms_pacifist% |
true if pacifism mode is enabled for this kingdom, otherwise false. |
%kingdoms_max_lands_modifier% |
Extra lands that are given to the kingdom by admins from the /k admin maxLandModifier command. |
%kingdoms_server_kingdom_tax% |
The amount of money your kingdom has to pay to server for taxes. |
%kingdoms_nation_tax% |
The amount of money your kingdom has to pay to your nation for taxes. |
%kingdoms_kingdom_tax% |
The amount of money your kingdom has to pay for taxes. This is the same as %kingdoms_server_kingdom_tax% if the kingdom is not in a nation, or %kingdoms_nation_tax% if the kingdom is in a nation. |
%kingdoms_structures_total% |
Total number of structures in kingdom. |
%kingdoms_turrets_total% |
Total number of structures in kingdom. |
%kingdoms_structures:count style=<name>% |
Total number of of a specific structure in the kingdom. E.g. %kingdoms_structures powercell%
|
%kingdoms_turrets:count style=<name>% |
Total number of of a specific structure in the kingdom. E.g. %kingdoms_turrets arrow%
|
| Placeholder | Description |
|---|---|
%kingdoms_nation% |
Your kingdom's nation name. |
%kingdoms_nation_kingdoms% |
The amount of kingdoms that are in your nation. |
%kingdoms_nation_spawn% |
Your kingdom's nation spawn location. |
%kingdoms_nation_bank% |
Kingdom bank money balance. |
%kingdoms_nation_since% |
The date your nation was created in year-month-day format. |
%kingdoms_nation_resource_points% |
Nation resource points. |
%kingdoms_nation_might% |
Nation might rank. |
%kingdoms_nation_capital% |
Nation's capital kingdom name. |
%kingdoms_nation_tax% |
Nation's tax for kingdoms. |
%kingdoms_server_nation_tax% |
The amount of money your nation has to pay to server for taxes. |
%kingdoms_nation_shield_since% |
Time that you activated your nation shield. |
%kingdoms_nation_shield_time% |
Your nation shield duration. |
%kingdoms_nation_shield_time_left% |
Nation shield time left. |
Not many plugins support relational placeholders. They can only be used in other plugins if you have PlaceholderAPI plugin installed, however like normal placeholders, they'll work internally in Kingdoms plugin without PAPI installed. Relational placeholders are placeholders that require two players. This will check the kingdom relation between them to make new special placeholders.
If you're using these placeholders from PlaceholderAPI you need to add rel_ at the beginning, so the format would be %rel_<placeholder>%
| Placeholder | Description |
|---|---|
%kingdoms_relation_name% |
The relation name defined in relations.yml between your kingdoms. |
%kingdoms_relation_color% |
The relation color defined in relations.yml between your kingdoms. |
These placeholders can be used with no context. They don't require a player, kingdom, nation and etc.
| Placeholder | Description |
|---|---|
%kingdoms_top:at pos=<position> of=<placeholder>% |
The placeholder used to retrieve one of the kingdoms that corresponds to what /k top returns. <position> starts from 1 and <placeholder> is simply the placeholder's name as you'd normally use excluding percents and kingdoms prefix. For example, %kingdoms_top 5 name% would show %kingdoms_name% as if it was used for the 5th kingdom. Use this placeholder sparingly as it can impact performance when used a lot. |
Terminology - Spigot - Discord - History - Other Info
- ๐ Home
- ๐ฐ Features
- ๐ฅ Installation
- ๐ Setup
- ๐ Compatibility
- โ FAQ
โ๏ธ NFAQ- โ๏ธ Addons
- ๐ฉ Outposts
- โฎ๏ธ Peace Treaties
- ๐บ๏ธ Map Viewers
- ๐ฌ EngineHub
- ๐ Admin Tools
- โ๏ธ Introduction
- โจ๏ธ Commands
- ๐ Permissions
- ๐ฃ Placeholders
- ๐ Config
- ๐ Protection Signs
- โ๏ธ Mails
- ๐ Mechanics
- ๐งฐ Troubleshooting
- ๐ป API
๐น Basics
๐น Turrets & Structures
๐น Metadata
๐น Events
๐น Examples
๐น Addons