diff --git a/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt b/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt index 8192cd4c..1ea3484c 100644 --- a/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt +++ b/src/main/kotlin/net/axay/kspigot/chat/LiteralTextBuilder.kt @@ -106,6 +106,26 @@ class LiteralTextBuilder(val internalText: BaseComponent, ) { ) } + /** + * Sets the command which should be executed by the Player if he clicks + * on the text. + * + * @param command the command which should be executed, the `/ should be added here + * @param onlySuggest if true, the command won't be executed immediately, + * instead it will be suggested in the command prompt + */ + fun onClickCommand(command: String, onlySuggest: Boolean = false) { + clickEvent = ClickEvent(if (onlySuggest) ClickEvent.Action.SUGGEST_COMMAND else ClickEvent.Action.RUN_COMMAND, command) + } + + /** + * Sets the String which should be copied to the clipboard if the + * Player clicks on this text. + */ + fun onClickCopy(copyText: String) { + clickEvent = ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, copyText) + } + /** * Adds a line break. */