Class TextPlaceholder

java.lang.Object
com.kamikazejam.kamicommon.nms.text.TextPlaceholder

public final class TextPlaceholder extends Object
A MiniMessage tag replacement, expressed as data rather than as a wrapped Adventure resolver.

Pass these to VersionedComponentSerializer#fromMiniMessage(String, TextPlaceholder...). The versions/* module converts them into whichever resolver its server needs, which is the point: this class deliberately holds no Adventure type. Wrapping a TagResolver here would be more convenient and would move the leak rather than close it, invisibly, because the field would be private.

The three factories mirror the three Adventure offers: an unparsed literal, a nested MiniMessage string, and an already-built component.

  • Method Details

    • literal

      @NotNull public static @NotNull TextPlaceholder literal(@NotNull @NotNull String key, @NotNull @NotNull String value)
      A replacement inserted verbatim. MiniMessage syntax inside value is not interpreted, which is what you want for anything user-supplied.
      Parameters:
      key - the tag name, without angle brackets
    • miniMessage

      @NotNull public static @NotNull TextPlaceholder miniMessage(@NotNull @NotNull String key, @NotNull @NotNull String value)
      A replacement parsed as MiniMessage before insertion.
      Parameters:
      key - the tag name, without angle brackets
    • component

      @NotNull public static @NotNull TextPlaceholder component(@NotNull @NotNull String key, @NotNull @NotNull VersionedComponent value)
      A replacement that is an already-built component, so it can carry its own click and hover behaviour. This is the form that replaces reaching through VersionedComponent#asInternalComponent() to build an Adventure Placeholder.
      Parameters:
      key - the tag name, without angle brackets
    • getKey

      @NotNull public @NotNull String getKey()
      The tag name, without angle brackets.
    • getKind

      @NotNull public @NotNull TextPlaceholder.Kind getKind()
      Which form this placeholder carries.
    • getStringValue

      @Nullable public @Nullable String getStringValue()
    • getComponentValue

      @Nullable public @Nullable VersionedComponent getComponentValue()
      The component value for TextPlaceholder.Kind.COMPONENT, else null.
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object