Interface PlaceholderService
public interface PlaceholderService
Lets addons add their own values to Zentrix's
%zentrix_...% placeholders.
An addon registers a namespace and a resolver; its values render as
%zentrix_<namespace>:<key>% everywhere Zentrix placeholders work - scoreboards, chat
formats, nametags, and any other plugin that renders PlaceholderAPI text. The : keeps
them apart from Zentrix's own placeholders, so an addon can never shadow or change those.
Example
ZentrixAPI.get().getPlaceholderService().register(this, "bounty",
(player, key) -> key.equals("amount") && player != null
? String.valueOf(bounties.get(player.getUniqueId()))
: null);
// %zentrix_bounty:amount%
- Since:
- 1.8.0
-
Method Summary
Modifier and TypeMethodDescriptionThe namespaces currently registered.@NotNull Registrationregister(@NotNull org.bukkit.plugin.Plugin owner, @NotNull String namespace, @NotNull PlaceholderResolver resolver) Registers an addon's placeholders under a namespace.Renders one addon placeholder directly, without PlaceholderAPI.
-
Method Details
-
register
@NotNull @NotNull Registration register(@NotNull @NotNull org.bukkit.plugin.Plugin owner, @NotNull @NotNull String namespace, @NotNull @NotNull PlaceholderResolver resolver) Registers an addon's placeholders under a namespace.- Parameters:
owner- the registering plugin; the placeholders are removed when it is disablednamespace- lowercase letters, digits,_and-, such as the addon's idresolver- supplies the values- Returns:
- the registration, to remove the placeholders early
- Throws:
IllegalArgumentException- if the namespace is malformed, iszentrix, or is already registered by an enabled plugin
-
getNamespaces
The namespaces currently registered. -
resolve
@NotNull @NotNull Optional<String> resolve(@Nullable @Nullable org.bukkit.OfflinePlayer player, @NotNull @NotNull String identifier) Renders one addon placeholder directly, without PlaceholderAPI.- Parameters:
player- the player to render it for, ornullidentifier-namespace:key, without the%zentrix_and%- Returns:
- the value, or empty when no registered resolver supplies one
-