Class PlaceholderDefinition

java.lang.Object
me.yleoft.zAPI.placeholders.PlaceholderDefinition

public class PlaceholderDefinition extends Object
Represents a single placeholder entry for MiniPlaceholders registration.

This defines a key that will be registered as a MiniPlaceholders tag, along with how many colon-separated arguments it expects and what type of placeholder it is.

Example definitions and their resulting usage:

  • ("version", 0, GLOBAL) → <zhomes_version> (no audience needed)
  • ("home", 1, AUDIENCE) → <zhomes_home:1> (uses viewing player)
  • ("home_world", 1, AUDIENCE) → <zhomes_home_world:1>
  • ("home", 1, PLAYER_TARGETED) → <zhomes_home:Steve:1> (targets "Steve")
  • ("has_home", 1, PLAYER_TARGETED) → <zhomes_has_home:Steve:base>

For PlaceholderType.PLAYER_TARGETED, the parameterCount does not include the player-name argument — that is prepended automatically. So if you define ("home", 1, PLAYER_TARGETED), usage is <zhomes_home:Steve:1> (player + 1 param).

  • Constructor Details

    • PlaceholderDefinition

      public PlaceholderDefinition(@NotNull @NotNull String key, int parameterCount, @NotNull @NotNull PlaceholderType type)
      Creates a placeholder definition with an explicit type.
      Parameters:
      key - The placeholder key (e.g., "home_name", "home_world")
      parameterCount - The number of colon-separated arguments this placeholder expects (excluding the player-name arg for PLAYER_TARGETED)
      type - The placeholder type
    • PlaceholderDefinition

      public PlaceholderDefinition(@NotNull @NotNull String key, int parameterCount)
      Creates a placeholder definition (defaults to PlaceholderType.AUDIENCE).
      Parameters:
      key - The placeholder key
      parameterCount - The number of colon-separated arguments this placeholder expects
    • PlaceholderDefinition

      public PlaceholderDefinition(@NotNull @NotNull String key)
      Creates a placeholder definition with no parameters (defaults to PlaceholderType.AUDIENCE).
      Parameters:
      key - The placeholder key
  • Method Details

    • getKey

      @NotNull public @NotNull String getKey()
      Gets the placeholder key.
      Returns:
      The key (e.g., "home_world")
    • getParameterCount

      public int getParameterCount()
      Gets the number of parameters this placeholder expects. For PlaceholderType.PLAYER_TARGETED, this does NOT include the player name.
      Returns:
      The parameter count
    • getType

      @NotNull public @NotNull PlaceholderType getType()
      Gets the placeholder type.
      Returns:
      The PlaceholderType
    • hasParameters

      public boolean hasParameters()
      Whether this placeholder has parameters.
      Returns:
      true if it has at least one parameter