ClickableMessage

A chat message the user can interact with.

Clickable messages allow setting mouse interactions by clicking, shift + clicking and hovering. Formatting and actions are inherited to all text components but can be overwritten by individual text components. To start building a message use message and declarative style kotlin syntax.

Functions

Link copied to clipboard
open override fun bold(bold: Boolean)

Sets the font to bold.

Link copied to clipboard
open override fun color(color: TextColor)

Sets the color for the component.

Link copied to clipboard
open override fun copyToClipboard(text: String)

Copies the given text to the users clipboard when they click on the message.

Link copied to clipboard
open override fun hoverEvent(eventSource: HoverEventSource<*>)

Sets the source for the content when hovering over the message. Can be many things, e.g., a text component, item, entity, etc.

Link copied to clipboard
open override fun hoverMessage(init: Message.() -> Unit)

Sets the hover message displayed when the user hovers the mouse over the text.

open override fun hoverMessage(message: String, init: Text.() -> Unit)

Sets the text displayed as hover-message when the user hovers the mouse over the text.

Link copied to clipboard
open override fun insert(text: String)

Sets the text appended to the client's text input when the user shift + left-clicks a message.

Link copied to clipboard
open override fun italic(italic: Boolean)

Sets the font to italic.

Link copied to clipboard
fun legacyText(legacyText: String, init: ClickableText.() -> Unit = {})

Adds a new text component from a legacy message formatted with § and color codes. Useful for things such as player display names.

Link copied to clipboard
fun newLine()

Adds a newline to the message content.

Link copied to clipboard
open override fun obfuscated(obfuscated: Boolean)

Obfuscates text by switching each letter between multiple characters. Will result in non-readable text.

Link copied to clipboard
open override fun openUrl(url: String)

Opens the "open URL" dialog when the user clicks on the message.

Link copied to clipboard
open override fun runCommand(command: String)

Runs a command when left-clicking on the text as the user who clicked the message.

Link copied to clipboard
fun space()

Adds a space to the message content.

Link copied to clipboard
open override fun strikeThrough(strikeThrough: Boolean)

Strikes the text through.

Link copied to clipboard
open override fun suggestCommand(command: String)

Inserts a command into the client's chat bar of the user who clicked the message.

Link copied to clipboard
fun text(text: String, init: ClickableText.() -> Unit = {})
fun text(component: Component, init: ClickableText.() -> Unit = {})

Adds a new text component to the message.

fun text(text: String, color: TextColor)

Convenience method to build a simple colorized message. For more flexible messages, use the overloaded version.

Link copied to clipboard
fun toChatMessage(): TextComponent

Converts the message to a TextComponent to use with the Chat API.

Link copied to clipboard
open override fun underlined(underlined: Boolean)

Underlines the text.