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/ChatUtils.kt | |
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/ChatUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt | 15 |
1 files changed, 15 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 |