component
Creates a text component using a DSL builder pattern.
This function provides a convenient way to construct Adventure text components using a builder DSL. The consumer lambda receives a ComponentBuilder instance that allows building the component structure declaratively.
Return
The built Component instance
Example usage:
val message = component {
text("Hello, ")
text("World!") {
color(NamedTextColor.RED)
}
}Parameters
A lambda with receiver that configures the component builder
Creates a text component using a DSL builder pattern with a custom joiner function.
This function provides an advanced way to construct Adventure text components using a builder DSL with a customizable joining strategy. Unlike the simpler component overload, this allows you to specify how the built components should be combined.
The consumer lambda receives a ComponentBuilder instance that allows building the component structure declaratively. The joiner function determines how the components are assembled into the final Component result.
Return
The built Component instance as determined by the joiner function
Example usage with default joiner:
val message = component { // Uses default joiner
append("Hello, ")
append("World!")
}Example usage with custom separator joiner:
val list = component(joiner = { it.join(" | ") }) {
append("Item 1")
append("Item 2")
append("Item 3")
}
// Result: "Item 1 | Item 2 | Item 3"Example usage with collect joiner:
val collected = component(joiner = ComponentBuilder::collect) {
append("First")
append("Second")
append("Third")
}Example usage with custom join configuration:
val formatted = component(joiner = {
it.join(JoinConfiguration.separator(", ".convert)
.prefix("[".convert)
.suffix("]".convert))
}) {
append("A")
append("B")
append("C")
}
// Result: "[A, B, C]"Parameters
A function that takes a ComponentBuilder and returns a Component. This controls how the built components are joined together. Defaults to ComponentBuilder.join which concatenates components without a separator.
A lambda with receiver that configures the component builder
Converts this string into a Component by auto-detecting the format type.
Return
The deserialized component.
See also
Property accessor for converting this string into a Component.