Using PlaceHolderApi
Using placeholders in scripts
Method
Parameters:
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
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:
greetplr
Params:
to this server!
Last updated