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
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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumSupported click‐action types forsetClick(Click, String). -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription@NotNull net.md_5.bungee.api.chat.BaseComponent[]compile(org.bukkit.entity.Player player) Compile this component into an array of BungeeCordBaseComponentsuitable for sending via the Spigot API (e.g.static ChatComponent<?> fromString(String message) Create a newChatComponentfrom raw text without player context, using the defaultTakionLibsingleton.static ChatComponent<?> fromString(TakionLib lib, String message) Create a newChatComponentfrom raw text without player context, using the specifiedTakionLib.@NotNull StringReturns the raw chat text of this component, without any events or legacy codes.booleanCheck if this component has any click or hover events attached.default CAttach a click action by parsing a single"action:argument"string.default CAttach a click action by its name (alias) and argument.setClick(ChatComponent.Click click, String input) Attach a click action to this component.Attach a single‐line hover tooltip to this component.default CAttach 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
The internal URL‐matchingPatternused by BungeeCord'sTextComponentto auto-detect and underline URLs in legacy text.
-
-
Method Details
-
getMessage
Returns the raw chat text of this component, without any events or legacy codes.- Returns:
- the underlying message text (never
null)
-
setMessage
Set the raw chat text of this component, replacing any existing content.This method mutates the component in place and returns
thisfor chaining.- Parameters:
message- the new message text (nevernull)- Returns:
- this component, with the new message set
-
setClick
Attach a click action to this component.The component is mutated in place, and this same instance is returned for chaining. The
clickparameter determines whichClickEvent.Actionwill be used, andinputis the command, URL, or other argument.- Parameters:
click- the click action typeinput- the argument for the action (e.g. "/say hi", "http://...")- Returns:
- this component, with click event applied
-
setClick
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
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
Attach a hover tooltip to this component.Each element in
listbecomes a separate line in the hover display. Mutates this component and returnsthisfor chaining.- Parameters:
list- the lines of hover text (nevernull)- Returns:
- this component, with hover event applied
-
setHover
Attach a hover tooltip via varargs.- Parameters:
array- the lines of hover text- Returns:
- this component, with hover event applied
-
setHover
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:
trueif events are present,falseotherwise
-
compile
@NotNull @NotNull net.md_5.bungee.api.chat.BaseComponent[] compile(org.bukkit.entity.Player player) Compile this component into an array of BungeeCordBaseComponentsuitable for sending via the Spigot API (e.g.player.spigot().sendMessage(...)).- Parameters:
player- the targetPlayercontext for placeholder resolution (might benull)- Returns:
- the compiled
BaseComponentarray
-
fromString
Create a newChatComponentfrom raw text without player context, using the specifiedTakionLib.- Parameters:
lib- the TakionLib instance providing configurationmessage- the raw chat message- Returns:
- a fresh
ChatComponentinstance
-
fromString
Create a newChatComponentfrom raw text without player context, using the defaultTakionLibsingleton.- Parameters:
message- the raw chat message- Returns:
- a fresh
ChatComponentinstance
-