-
Notifications
You must be signed in to change notification settings - Fork 0
PlaceholderAPI
PlaceholderAPI support allows SimpleRanks to provide dynamic values (placeholders) that can be used in chat formats, scoreboards, tab lists, GUIs, and other plugins.
This page explains how the SimpleRanks PlaceholderExpansion works and how to use it.
PlaceholderAPI is a popular Spigot plugin that allows plugins to expose variables (called placeholders) which can be used in other plugins.
Placeholders look like this:
%identifier_placeholder%
In SimpleRanks, the identifier is:
%simpleranks_...%
The PlaceholderExpansion class registers SimpleRanks placeholders with PlaceholderAPI.
simpleranks
TomMustBe12
true
This means the expansion stays loaded even after PlaceholderAPI reloads.
When another plugin requests a placeholder like:
%simpleranks_rank%
PlaceholderAPI calls:
onPlaceholderRequest(Player player, String id)-
player→ the player the placeholder is being resolved for -
id→ the part aftersimpleranks_
Example:
%simpleranks_rank%
→ id = "rank"
The plugin then uses a switch statement to return the correct value.
Returns the fully formatted rank prefix, including color codes.
- Gets the player's rank
- Retrieves the prefix from config
- Translates
&color codes into Minecraft colors
[ADMIN]
Returns the raw rank name without formatting.
ADMIN
Returns only the prefix of the rank (with color applied).
&c[ADMIN] → [ADMIN] (colored in red)
Returns whether the rank is marked as important.
true
false
@Override
public @Nullable String onPlaceholderRequest(Player player, @NotNull String id)This method:
- Ensures the player is not null
- Matches the placeholder ID
- Returns the correct value
If no match is found:
return null;Example:
String rankName = rankManager.getRank(player.getUniqueId());- Retrieves the player's assigned rank
- Used in multiple placeholders
ChatColor.translateAlternateColorCodes('&', text);- Converts
&color codes into Minecraft formatting - Example:
&cADMIN→ red text
%simpleranks_rank% %player_name%: %message%
Rank: %simpleranks_raw_rank%
%simpleranks_prefix% %player_name%
- PlaceholderAPI installed
- SimpleRanks installed
- Expansion registered (automatically if coded in plugin)
- Placeholders require a valid player context
- If
player == null, an empty string is returned - Invalid placeholders return
null - All rank data is retrieved via
RankManager
- Use
%simpleranks_rank%for full formatting - Use
%simpleranks_raw_rank%for logic-based plugins - Combine with chat plugins for clean formatting
- Keep rank prefixes consistent in your config
SimpleRanks integrates with PlaceholderAPI by registering a custom expansion. This allows other plugins to dynamically access player rank data, making it easy to display ranks across your server.