Class PlaceholderRegistry

java.lang.Object
com.plotsquared.core.util.placeholders.PlaceholderRegistry

public final class PlaceholderRegistry extends Object
Registry that contains placeholders
  • Constructor Details

    • PlaceholderRegistry

      @Inject public PlaceholderRegistry(@NonNull EventDispatcher eventDispatcher)
  • Method Details

    • createPlaceholder

      public void createPlaceholder(@NonNull String key, @NonNull com.google.common.base.Function<PlotPlayer<?>,​String> placeholderFunction)
      Create a functional placeholder
      Parameters:
      key - Placeholder key
      placeholderFunction - Placeholder generator. Cannot return null
    • createPlaceholder

      public void createPlaceholder(@NonNull String key, @NonNull BiFunction<PlotPlayer<?>,​Plot,​String> placeholderFunction)
      Create a functional placeholder
      Parameters:
      key - Placeholder key
      placeholderFunction - Placeholder generator. Cannot return null
    • registerPlaceholder

      public void registerPlaceholder(@NonNull Placeholder placeholder)
      Register a placeholder
      Parameters:
      placeholder - Placeholder instance
    • getPlaceholder

      public @Nullable Placeholder getPlaceholder(@NonNull String key)
      Get a placeholder instance from its key
      Parameters:
      key - Placeholder key
      Returns:
      Placeholder value
    • getPlaceholderValue

      public @NonNull String getPlaceholderValue(@NonNull String key, @NonNull PlotPlayer<?> player)
      Get the placeholder value evaluated for a player, and catch and deal with any problems occurring while doing so
      Parameters:
      key - Placeholder key
      player - Player to evaluate for
      Returns:
      Replacement value
    • getPlaceholders

      public @NonNull Collection<Placeholder> getPlaceholders()
      Get all placeholders
      Returns:
      Unmodifiable collection of placeholders