ComponentBuilder

A builder interface for creating and manipulating Adventure text components. Provides fluent API methods for appending content, styling, and collecting components.

Properties

Link copied to clipboard

Extension property to append this string directly to the component builder. Provides a convenient property-style syntax for appending strings.

Link copied to clipboard
open val String.convert: Component

Extension property to convert this string into a Component using auto-detection. Automatically detects the component format type (legacy section, legacy ampersand, MiniMessage, or plain text) and deserializes the string accordingly.

Link copied to clipboard

Extension property to append this string as a keybind component. Uses this string as the keybind key to display the player's configured key.

Link copied to clipboard

Extension property to append this string as a selector component. Uses this string as the entity selector pattern (@a, @p, etc.).

Link copied to clipboard

Extension property to append this string as a translatable component. Uses this string as the translation key for localized text.

Functions

Link copied to clipboard
abstract infix fun append(content: String): ComponentBuilder

Appends a string content to this component builder.

abstract infix fun append(component: Component): ComponentBuilder

Appends a component to this component builder.

Link copied to clipboard

Sets the text color to aqua.

Link copied to clipboard

Sets the text color to black.

Link copied to clipboard
@ApiStatus.Experimental
abstract fun blockNbt(@Language(value = "NBTPath") nbt: String, consumer: BlockNBTComponent.Builder.() -> Unit): ComponentBuilder

Appends a block NBT component with the specified NBT path and builder configuration. Queries and displays NBT data from a block at a specific position.

Link copied to clipboard

Sets the text color to blue.

Link copied to clipboard

Sets the bold decoration of the last component added to this ComponentBuilder.

Link copied to clipboard
abstract fun collect(): Component

Collects all appended components into a single component without a separator.

abstract fun collect(separator: String): Component

Collects all appended components into a single component with a string separator.

abstract fun collect(separator: Component): Component

Collects all appended components into a single component with a component separator.

Link copied to clipboard
abstract infix fun create(consumer: ComponentBuilder.() -> Unit): ComponentBuilder

Creates a new component builder scope with the given consumer.

Link copied to clipboard

Sets the text color to dark aqua.

Link copied to clipboard

Sets the text color to dark blue.

Link copied to clipboard

Sets the text color to dark gray.

Link copied to clipboard

Sets the text color to dark green.

Link copied to clipboard

Sets the text color to dark purple.

Link copied to clipboard

Sets the text color to dark red.

Link copied to clipboard
@ApiStatus.Experimental
abstract fun entityNbt(@Language(value = "NBTPath") nbt: String, consumer: EntityNBTComponent.Builder.() -> Unit): ComponentBuilder

Appends an entity NBT component with the specified NBT path and builder configuration. Queries and displays NBT data from entities matching a selector.

Link copied to clipboard
Link copied to clipboard
abstract fun <T> forEach(iterable: Iterable<T>, action: ComponentBuilder.(T) -> Unit): ComponentBuilder

Iterates over the given iterable and applies an action to each element. The action receives both the component builder context and the current element, allowing component building per iteration.

Link copied to clipboard

Sets the text color to gold.

Link copied to clipboard

Sets the text color to gray.

Link copied to clipboard

Sets the text color to green.

Link copied to clipboard
abstract infix fun hoverEvent(event: HoverEvent<*>): ComponentBuilder

Applies a hover event to the last appended component. When the player hovers over this component, the specified hover event will be triggered.

Link copied to clipboard
abstract infix fun insertion(text: String): ComponentBuilder

Sets the insertion text for the last appended component. When the player shift-clicks this component, the specified text will be inserted into their chat input field.

Link copied to clipboard

Sets the italic decoration of the last component added to this ComponentBuilder.

Link copied to clipboard
abstract fun join(): Component

Joins all appended components into a single component without a separator.

open fun join(consumer: JoinConfiguration.Builder.() -> Unit): Component

Joins all appended components into a single component using a join configuration DSL.

abstract fun join(sep: String): Component

Joins all appended components into a single component with a string separator.

abstract fun join(sep: Component): Component

Joins all appended components into a single component with a component separator.

abstract fun join(conf: JoinConfiguration): Component

Joins all appended components into a single component using a join configuration.

Link copied to clipboard
open fun joinConfiguration(consumer: JoinConfiguration.Builder.() -> Unit): JoinConfiguration

Creates a new component join configuration using a DSL builder.

Link copied to clipboard
abstract infix fun keybind(key: String): ComponentBuilder

Appends a keybind component with the specified keybind key. Displays the key binding configured by the player (e.g., "key.inventory", "key.jump").

open fun keybind(key: String, styler: Styler.() -> Unit): ComponentBuilder

Appends a keybind component with the specified keybind key and applies additional configuration.

Link copied to clipboard
abstract fun mini(content: String, vararg tags: TagResolver): ComponentBuilder

Appends a MiniMessage string content to this component builder with optional tag resolvers.

open fun mini(content: String, tags: TagResolverBuilder.() -> Unit): ComponentBuilder

Appends a MiniMessage string content to this component builder with tag resolvers built using a consumer.

Link copied to clipboard
abstract fun newline(): ComponentBuilder

Appends a newline component to this component builder. Inserts a line break in the text display.

Link copied to clipboard

Sets the obfuscated decoration of the last component added to this ComponentBuilder.

Link copied to clipboard

Sets the text color to light purple.

Link copied to clipboard

Sets the text color to red.

Link copied to clipboard
abstract fun score(name: String, objective: String): ComponentBuilder

Appends a score component with the specified player name and objective.

open fun score(name: String, objective: String, styler: Styler.() -> Unit): ComponentBuilder

Appends a score component with the specified player name and objective and applies additional configuration.

Link copied to clipboard
abstract infix fun selector(key: String): ComponentBuilder

Appends a selector component with the specified selector pattern. Selectors target entities in the game world (e.g., "@a" for all players, "@p" for nearest player, "@etype=cow" for cows).

open fun selector(key: String, styler: Styler.() -> Unit): ComponentBuilder

Appends a selector component with the specified selector pattern and applies additional configuration.

Link copied to clipboard
abstract fun space(): ComponentBuilder

Appends a space component to this component builder. Inserts a single space character in the text display.

Link copied to clipboard
abstract fun storageNbt(@Language(value = "NBTPath") nbt: String, storage: String, consumer: StorageNBTComponent.Builder.() -> Unit): ComponentBuilder

Appends a storage NBT component that queries data from command storage. Displays NBT data from persistent command storage at the specified key (parsed from string).

@ApiStatus.Experimental
abstract fun storageNbt(@Language(value = "NBTPath") nbt: String, storage: Key, consumer: StorageNBTComponent.Builder.() -> Unit): ComponentBuilder

Appends a storage NBT component that queries data from command storage. Displays NBT data from persistent command storage at the specified key.

Link copied to clipboard

Sets the strikethrough decoration of the last component added to this ComponentBuilder.

Link copied to clipboard
abstract fun styleLast(style: Style): ComponentBuilder

Applies a style to the most recently appended component in this component builder. This allows retroactive styling of the last added component.

Link copied to clipboard
open fun tab(): ComponentBuilder

Appends a tab component to this component builder.

Link copied to clipboard
open fun text(content: String): ComponentBuilder

Appends a text component with the specified string content.

open fun text(content: String, consumer: Styler.() -> Unit): ComponentBuilder

Appends a text component with the specified string content and applies additional configuration. This method combines appending text with a nested component builder scope, allowing you to build complex component hierarchies in a fluent way.

Link copied to clipboard
open infix fun translatable(key: String): ComponentBuilder

Appends a translatable component with the specified translation key.

abstract fun translatable(key: String, vararg args: Component): ComponentBuilder

Appends a translatable component with component arguments. The arguments will be substituted into the translation pattern.

abstract fun translatable(key: String, consumer: ComponentBuilder.() -> Unit): ComponentBuilder

Appends a translatable component with arguments built using a consumer lambda.

abstract fun translatable(key: String, args: List<Component>): ComponentBuilder

Appends a translatable component with the specified translation key and a list of component arguments.

abstract fun translatable(key: String, style: Style): ComponentBuilder

Appends a translatable component with the specified translation key and style.

abstract fun translatable(key: String, styler: Styler.() -> Unit, consumer: ComponentBuilder.() -> Unit): ComponentBuilder

Appends a styled translatable component with arguments built using a nested component builder scope.

abstract fun translatable(key: String, styler: Styler.() -> Unit, args: List<Component>): ComponentBuilder

Appends a translatable component with the specified translation key, style, and list of arguments.

abstract fun translatable(key: String, style: Style, vararg args: Component): ComponentBuilder

Appends a translatable component with the specified translation key, style, and component arguments.

Link copied to clipboard
abstract fun translatableAny(key: String, vararg args: Any): ComponentBuilder

Appends a translatable component with mixed type arguments. Accepts any type of arguments (String, Number, Component, etc.) which will be converted appropriately.

Link copied to clipboard
open operator fun String.unaryPlus(): ComponentBuilder

Operator function to append a string to this component builder using the unary + operator.

open operator fun Component.unaryPlus(): ComponentBuilder

Operator function to append a component to this component builder using the unary + operator.

Link copied to clipboard

Sets the underline decoration of the last component added to this ComponentBuilder.

Link copied to clipboard
open fun whenFalse(condition: Boolean, consumer: ComponentBuilder.() -> Unit): ComponentBuilder

Conditionally applies a consumer lambda to this component builder if the condition is false.

Link copied to clipboard
abstract fun whenTrue(condition: Boolean, consumer: ComponentBuilder.() -> Unit): ComponentBuilder

Conditionally applies a consumer lambda to this component builder if the condition is true.

Link copied to clipboard

Sets the text color to white.

Link copied to clipboard

Sets the color of the last component added to this ComponentBuilder using an integer RGB value.

infix fun ComponentBuilder.withColor(color: TextColor): ComponentBuilder

Sets the color of the last component added to this ComponentBuilder.

Link copied to clipboard

Sets the font of the last component added to this ComponentBuilder using a font key string.

Sets the font of the last component added to this ComponentBuilder.

Link copied to clipboard
infix inline fun ComponentBuilder.withStyle(crossinline consumer: Styler.() -> Unit): ComponentBuilder

Applies a style to the last component added to this ComponentBuilder using a DSL builder pattern.

Link copied to clipboard

Sets the text color to yellow.