This plugin lets you configure your very own, custom, fixed
PAPI (PlaceholderAPI) placeholders, that you can then use everywhere in plugin configurations with the prefix
%custompapi_.
A typical example would be that you have a URL of a webpage with content about your Minecraft server. You want to display that URL in various places, like in the chat when entering a custom command, in a link in a custom book, in a link in a scoreboard etc. For all these things you usually use different plugins, and each plugin has its own configuration file where you would enter that. So instead of having to configure that URL in multiple different places, you configure just one custom static placeholder with a property like this:
homepage=http://www.acme.com
and then use it in all the plugin configuration file (assuming most plugins support PAPI) with the placeholder
%custompapi_homepage%.
Configuration
The custom placeholders are configured in a simple Java property file in this location:
/plugins/MyCustomPlaceholders/myCustomPlaceholders.properties
Apart from comments (lines beginning with '#'), each line contains one key and value, e.g.
rankHeroTab=<&5HERO>
rankHeroChat=[&5HERO]
With this example, the placeholder
%custompapi_rankHeroTab% could then be used in a plugin like "TAB" to display the player's rank in the tab scoreboard, while the placeholder
%custompapi_rankHeroChat% could be used with a chat plugin for the chat name prefix.
Change placeholder value at runtime
The command "set" allows to set a configured placeholder to a specific value at runtime:
/cpapi set rankHeroTab=<&4&lSuperHero&r&0>
NOTE: This change is not persisted. The placeholder will revert back to the configured value at the next server restart.
Internal Placeholder References
Sometimes you also want to avoid redundant text labels within this configuration file, like the redundant text "
HERO" in the example above, including the color code prefix "
&5". For that, you can basically define an "internal" constant, i.e. a property whose value is used by other placeholder properties. To reference a property from another one, the string must be the name of the referenced property, prefixed by `
${` and followed by `
}`. Example:
rankHero=&5HERO
rankHeroTab=<${rankHero}>
rankHeroChat=[${rankHero}]
It is also possible to use multiple such internal references within one property value, e.g.:
rankOne=HERO
rankTwo=ELITE
rankThree=MASTER
allRanks=Ranks: ${rankOne}, ${rankTwo}, ${rankThree}
PlaceholderAPI (PAPI) references
The property aka placeholder values in this configuration file can also contain other PAPI placeholders themselves. Example:
serverLabel=Name: %server_name%, Version: %server_version%
And then use the placeholder
%custompapi_serverLabel% anyhwere to display this label.
Minecraft Versions
Has been tested in Spigot 1.8 and Paper 1.18.1. I assume it also runs in all versions in between.
1.8 GSON "NoClassDefFoundError" Issue
NOTE: When running in a server of version 1.8.3 or older, you will need to add the Google GSON library. You can do this by simply installing this plugin:
https://www.spigotmc.org/resources/gson-for-1-8-3-or-older.30852/