Class KeyPlaceholder

java.lang.Object
ua.mcchickenstudio.opencreative.coding.placeholders.Placeholder
ua.mcchickenstudio.opencreative.coding.placeholders.KeyPlaceholder
All Implemented Interfaces:
ExtensionContent
Direct Known Subclasses:
EntityPlaceholder, EventPlaceholder, PlanetPlaceholder, PlayerPlaceholder, RandomPlaceholder, SymbolPlaceholder, TargetPlaceholder

public abstract class KeyPlaceholder extends Placeholder

KeyPlaceholder

This class represents a key placeholder, that has keys that will be replaced, if text will contain them in "percents format": %example% Should be used for creation.
  • Constructor Details

    • KeyPlaceholder

      public KeyPlaceholder(String... keys)
  • Method Details

    • getPatternPlaceholder

      public static Pattern getPatternPlaceholder()
    • matches

      public boolean matches(String text)
      Description copied from class: Placeholder
      Returns true if specified text contains placeholders that can be parsed with this class.
      Specified by:
      matches in class Placeholder
      Parameters:
      text - text to check.
      Returns:
      true - placeholders detected, false - not detected.
    • getKeys

      public String[] getKeys()
      Returns array of keys that can be replaced, without %.
      Returns:
      array of keys.
    • parseKey

      @Nullable public abstract @Nullable String parseKey(String key, ActionsHandler handler, Action action)
      Parses placeholder key, without %.
      Parameters:
      key - key to replace.
      handler - action handler.
      action - action
      Returns:
      string - if parsed, or null - nothing parsed.
    • parse

      @NotNull public @NotNull String parse(String text, ActionsHandler handler, Action action)
      Description copied from class: Placeholder
      Returns text with parsed placeholders from this class.
      Specified by:
      parse in class Placeholder
      Parameters:
      text - text to parse.
      handler - action handler.
      action - action.
      Returns:
      parsed text