PlaceHolderApi integration
Using placeholders in scripts
To ensure PlaceholderAPI integration for any script, add the feature flag:
//!PlaceholderAPIMethod
PlaceholderAPI.parseString(player: Player, input: String): StringParameters:
player (
Player): The player for whom the placeholder should be parsed.input (
String): The string containing one or more placeholders (e.g.,%placeholder%).
Returns:
String: A copy of the input string with all placeholders replaced with their actual values.
Example
registerEvent("org.bukkit.event.player.PlayerJoinEvent", {
handleEvent: function(event) {
var player = event.getPlayer()
var message = "Placeholder data: %placeholder%"
var parsedMsg = PlaceholderAPI.parseString(player, message)
player.sendMessage(parsedMsg)
}
})Creating placeholders with scripts
Method: PlaceholderAPI.registerPlaceholder(prefix, listener)
prefix (
String): The unique identifier for your placeholder. It will be used in the placeholder format%openjs_<prefix>_<params>%listener (
Object): An object containing anonRequest(player, params)method, which will be called whenever the placeholder is parsed
Parameter: onRequest(player: Player | null, params: String | null): String
player (
Player | null) The player for whom the placeholder is being resolved. Can be null (e.g., if not run in a player context)params (
String | null) The parameter string following your prefix in the placeholder. Can also be null.
Placeholder Syntax
Example:
%openjs_greetplr_to this server!%Prefix:
greetplrParams:
to this server!
Removing placeholders with scripts
Parameters:
prefix (
String): The unique identifier for your placeholder. It will be used in the placeholder format%openjs_<prefix>_<params>%
Last updated
Was this helpful?