Interface ChatComponent<C extends ChatComponent<C>>

Type Parameters:
C - the concrete subtype of this component (for fluent builders)
All Superinterfaces:
BaseBuilder<C>
All Known Subinterfaces:
MultiComponent

public interface ChatComponent<C extends ChatComponent<C>> extends BaseBuilder<C>
Represents a rich, mutable chat component that can carry click and hover actions.

A ChatComponent<C> wraps a legacy‐format TextComponent message and allows optional ClickEvent and HoverEvent to be attached. It implements BaseBuilder so all mutator methods return this (of type C) for fluent chaining.

After configuring message, click, and hover, call compile(Player) to obtain the BungeeCord BaseComponent array ready for sending via Spigot.

See Also:
  • TextComponent
  • ClickEvent
  • HoverEvent
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Supported click‐action types for setClick(Click, String).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Pattern
    The internal URL‐matching Pattern used by BungeeCord's TextComponent to auto-detect and underline URLs in legacy text.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull net.md_5.bungee.api.chat.BaseComponent[]
    compile(org.bukkit.entity.Player player)
    Compile this component into an array of BungeeCord BaseComponent suitable for sending via the Spigot API (e.g.
    static ChatComponent<?>
    fromString(String message)
    Create a new ChatComponent from raw text without player context, using the default TakionLib singleton.
    static ChatComponent<?>
    fromString(TakionLib lib, String message)
    Create a new ChatComponent from raw text without player context, using the specified TakionLib.
    @NotNull String
    Returns the raw chat text of this component, without any events or legacy codes.
    boolean
    Check if this component has any click or hover events attached.
    default C
    Attach a click action by parsing a single "action:argument" string.
    default C
    setClick(String click, String input)
    Attach a click action by its name (alias) and argument.
    Attach a click action to this component.
    setHover(String string)
    Attach a single‐line hover tooltip to this component.
    default C
    setHover(String... array)
    Attach a hover tooltip via varargs.
    Attach a hover tooltip to this component.
    setMessage(@NotNull String message)
    Set the raw chat text of this component, replacing any existing content.

    Methods inherited from interface me.croabeast.common.builder.BaseBuilder

    instance
  • Field Details

    • URL_PATTERN

      static final Pattern URL_PATTERN
      The internal URL‐matching Pattern used by BungeeCord's TextComponent to auto-detect and underline URLs in legacy text.
  • Method Details

    • getMessage

      @NotNull @NotNull String getMessage()
      Returns the raw chat text of this component, without any events or legacy codes.
      Returns:
      the underlying message text (never null)
    • setMessage

      @NotNull C setMessage(@NotNull @NotNull String message)
      Set the raw chat text of this component, replacing any existing content.

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

      Parameters:
      message - the new message text (never null)
      Returns:
      this component, with the new message set
    • setClick

      @NotNull C setClick(ChatComponent.Click click, String input)
      Attach a click action to this component.

      The component is mutated in place, and this same instance is returned for chaining. The click parameter determines which ClickEvent.Action will be used, and input is the command, URL, or other argument.

      Parameters:
      click - the click action type
      input - the argument for the action (e.g. "/say hi", "http://...")
      Returns:
      this component, with click event applied
    • setClick

      @NotNull default C setClick(String click, String input)
      Attach a click action by its name (alias) and argument.

      Convenience for setClick(Click.fromName(click), input).

      Parameters:
      click - the click action name or alias (e.g. "run", "url")
      input - the argument for the action
      Returns:
      this component, with click event applied
    • setClick

      @NotNull default C setClick(String input)
      Attach a click action by parsing a single "action:argument" string.

      Splits on the first ':'; if none is present, uses an empty argument. Quotation marks are removed before parsing.

      Parameters:
      input - the combined action and argument (e.g. "run:/tp 5 64 5")
      Returns:
      this component, with click event applied
    • setHover

      @NotNull C setHover(List<String> list)
      Attach a hover tooltip to this component.

      Each element in list becomes a separate line in the hover display. Mutates this component and returns this for chaining.

      Parameters:
      list - the lines of hover text (never null)
      Returns:
      this component, with hover event applied
    • setHover

      @NotNull default C setHover(String... array)
      Attach a hover tooltip via varargs.
      Parameters:
      array - the lines of hover text
      Returns:
      this component, with hover event applied
    • setHover

      @NotNull C setHover(String string)
      Attach a single‐line hover tooltip to this component.
      Parameters:
      string - the hover text line
      Returns:
      this component, with hover event applied
    • hasEvents

      boolean hasEvents()
      Check if this component has any click or hover events attached.
      Returns:
      true if events are present, false otherwise
    • compile

      @NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent[] compile(org.bukkit.entity.Player player)
      Compile this component into an array of BungeeCord BaseComponent suitable for sending via the Spigot API (e.g. player.spigot().sendMessage(...)).
      Parameters:
      player - the target Player context for placeholder resolution (might be null)
      Returns:
      the compiled BaseComponent array
    • fromString

      static ChatComponent<?> fromString(TakionLib lib, String message)
      Create a new ChatComponent from raw text without player context, using the specified TakionLib.
      Parameters:
      lib - the TakionLib instance providing configuration
      message - the raw chat message
      Returns:
      a fresh ChatComponent instance
    • fromString

      static ChatComponent<?> fromString(String message)
      Create a new ChatComponent from raw text without player context, using the default TakionLib singleton.
      Parameters:
      message - the raw chat message
      Returns:
      a fresh ChatComponent instance