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 Type
    Method
    Description
    @NotNull Set<String>
    The namespaces currently registered.
    @NotNull Registration
    register(@NotNull org.bukkit.plugin.Plugin owner, @NotNull String namespace, @NotNull PlaceholderResolver resolver)
    Registers an addon's placeholders under a namespace.
    @NotNull Optional<String>
    resolve(@Nullable org.bukkit.OfflinePlayer player, @NotNull String identifier)
    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 disabled
      namespace - lowercase letters, digits, _ and -, such as the addon's id
      resolver - supplies the values
      Returns:
      the registration, to remove the placeholders early
      Throws:
      IllegalArgumentException - if the namespace is malformed, is zentrix, or is already registered by an enabled plugin
    • getNamespaces

      @NotNull @NotNull Set<String> 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, or null
      identifier - namespace:key, without the %zentrix_ and %
      Returns:
      the value, or empty when no registered resolver supplies one