diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-22 18:16:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-22 18:16:49 +0100 |
commit | a8138b0aa20d2b2fd266b1352eaf075999365bb6 (patch) | |
tree | a9c15556e699c00869bae2fe811e309727b204c8 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 788adb59f20e01c83f4e030fa077a70275c00074 (diff) | |
download | skyhanni-a8138b0aa20d2b2fd266b1352eaf075999365bb6.tar.gz skyhanni-a8138b0aa20d2b2fd266b1352eaf075999365bb6.tar.bz2 skyhanni-a8138b0aa20d2b2fd266b1352eaf075999365bb6.zip |
Backend: ChatClickActionManager (#1128)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt | 15 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt index ae04b4535..d2f12b1d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.ChatClickActionManager import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -128,6 +129,20 @@ object ChatUtils { } /** + * Sends a message to the user that they can click and run an action + * @param message The message to be sent + * @param onClick The runnable to be executed when the message is clicked + * @param prefix Whether to prefix the message with the chat prefix, default true + * @param prefixColor Color that the prefix should be, default yellow (§e) + * + * @see CHAT_PREFIX + */ + fun clickableChat(message: String, onClick: () -> Any, prefix: Boolean = true, prefixColor: String = "§e") { + val msgPrefix = if (prefix) prefixColor + CHAT_PREFIX else "" + ChatClickActionManager.oneTimeClick(msgPrefix + message, onClick) + } + + /** * Sends a message to the user that they can click and run a command * @param message The message to be sent * @param hover The message to be shown when the message is hovered diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index a937b6f12..bcb185f60 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -299,4 +299,6 @@ object StringUtils { fun String.isRoman(): Boolean = UtilsPatterns.isRomanPattern.matches(this) fun isEmpty(message: String): Boolean = message.removeColor().trimWhiteSpaceAndResets().isEmpty() + + fun generateRandomId() = UUID.randomUUID().toString() } |