Interface MultiComponent

All Superinterfaces:
BaseBuilder<MultiComponent>, ChatComponent<MultiComponent>, Copyable<MultiComponent>

public interface MultiComponent extends ChatComponent<MultiComponent>, Copyable<MultiComponent>
A composite chat component that can parse a formatted string into multiple ChatComponent segments and allows fluent manipulation of all segments.

A MultiComponent extends ChatComponent to support complex text containing interleaved click and hover directives. It also implements Copyable to produce deep copies of itself.

Parsing and formatting is driven by a Format obtained via getFormat(), which defaults to DEFAULT_FORMAT. New instances can be created via the static fromString(...) methods.

See Also:
  • Field Details

    • CLICK_REGEX

      static final String CLICK_REGEX
      Regular expression for matching click actions in the format strings.

      Supports aliases such as "run", "suggest", "url", "file", "page", "copy", etc.

      See Also:
    • DEFAULT_REGEX

      static final String DEFAULT_REGEX
      Default format pattern for parsing text with optional hover and click directives.

      Matches constructs of the form: <action:"argument"[|action:"argument"]>text</text> (case-insensitive).

      See Also:
    • DEFAULT_FORMAT

      static final Format<ChatComponent<?>> DEFAULT_FORMAT
      The default Format instance used by new MultiComponent objects.

      Uses DEFAULT_REGEX and produces individual ChatComponent segments for each match.

  • Method Details

    • setMessage

      @NotNull default @NotNull MultiComponent setMessage(@NotNull @NotNull String message)
      Description copied from interface: ChatComponent
      Set the raw chat text of this component, replacing any existing content.

      This method mutates the component in place and returns this for chaining.

      Specified by:
      setMessage in interface ChatComponent<MultiComponent>
      Parameters:
      message - the new message text (never null)
      Returns:
      this component, with the new message set
    • getFormat

      @NotNull @NotNull Format<ChatComponent<?>> getFormat()
      Gets the Format used to parse and render this component.
      Returns:
      the current Format for this multi-component (never null)
    • setFormat

      @NotNull @NotNull MultiComponent setFormat(@NotNull @NotNull Format<ChatComponent<?>> format)
      Sets a custom Format for parsing this component.

      Subsequent invocations of append(String) or initial parsing via fromString(...) will use this format.

      Parameters:
      format - the new format to apply (must not be null)
      Returns:
      this component, with the format updated
    • hasEvents

      boolean hasEvents()
      Checks if this component has any segments with events (click or hover).
      Specified by:
      hasEvents in interface ChatComponent<MultiComponent>
      Returns:
      true if any segments have events, false otherwise
    • append

      @NotNull @NotNull MultiComponent append(String message)
      Appends a raw text segment to this component.

      The segment is parsed by the current format and merged with existing segments.

      Parameters:
      message - the raw text to append
      Returns:
      this component, with the text appended
    • append

      @NotNull @NotNull MultiComponent append(@NotNull @NotNull ChatComponent<?> component)
      Appends an existing ChatComponent to this multi-component.
      Parameters:
      component - the component to append (must not be null)
      Returns:
      this component, with the segment appended
    • append

      @NotNull default @NotNull MultiComponent append(Object object)
      Appends an object's toString() value as a text segment.
      Parameters:
      object - the object whose string form will be appended
      Returns:
      this component, with the object's text appended
    • setClickToAll

      @NotNull @NotNull MultiComponent setClickToAll(ChatComponent.Click click, String input)
      Applies a click action uniformly to all segments in this component.
      Parameters:
      click - the click action type to apply
      input - the argument for the click action
      Returns:
      this component, with click events applied to every segment
    • setClickToAll

      @NotNull default @NotNull MultiComponent setClickToAll(String click, String input)
      Applies a click action (by name) uniformly to all segments.
      Parameters:
      click - the click action name or alias
      input - the argument for the click action
      Returns:
      this component, with click events applied to every segment
    • setClickToAll

      @NotNull default @NotNull MultiComponent setClickToAll(String input)
      Applies a click action (parsed from a single "action:argument" string) uniformly to all segments.
      Parameters:
      input - the combined action and argument string
      Returns:
      this component, with click events applied to every segment
    • setHoverToAll

      @NotNull @NotNull MultiComponent setHoverToAll(List<String> list)
      Applies a hover tooltip uniformly to all segments.
      Parameters:
      list - the lines of hover text
      Returns:
      this component, with hover events applied to every segment
    • setHoverToAll

      @NotNull default @NotNull MultiComponent setHoverToAll(String... strings)
      Applies a hover tooltip (via varargs) uniformly to all segments.
      Parameters:
      strings - the lines of hover text
      Returns:
      this component, with hover events applied to every segment
    • setHoverToAll

      @NotNull @NotNull MultiComponent setHoverToAll(String string)
      Applies a single-line hover tooltip uniformly to all segments.
      Parameters:
      string - the hover text line
      Returns:
      this component, with hover events applied to every segment
    • toFormattedString

      @NotNull default @NotNull String toFormattedString()
      Converts this multi-component into a single formatted string.

      The string is generated using the current format.

      Returns:
      the formatted string representation of this component
    • fromString

      static MultiComponent fromString(TakionLib lib, String message)
      Creates a new MultiComponent from the given raw message, using the specified TakionLib instance for formatting rules.
      Parameters:
      lib - the TakionLib providing configuration
      message - the raw chat message (may include formatting tokens)
      Returns:
      a new MultiComponent parsed from message
    • fromString

      static MultiComponent fromString(String message)
      Creates a new MultiComponent from the given raw message, using the default TakionLib singleton.
      Parameters:
      message - the raw chat message (may include formatting tokens)
      Returns:
      a new MultiComponent parsed from message