diff options
| author | Obsidian <108832807+Obsidianninja11@users.noreply.github.com> | 2024-02-09 13:40:02 -0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-09 23:40:02 +0100 |
| commit | 9cfdf252304e3fe270bd84ddcae292273a9927aa (patch) | |
| tree | de3c91cc8b155ec15c21cb8646a322cbe44e478d /src/main/java/at/hannibal2/skyhanni/utils | |
| parent | d134fece41b7cfe4d8ff1c9176ff0e7f8a05420f (diff) | |
| download | skyhanni-9cfdf252304e3fe270bd84ddcae292273a9927aa.tar.gz skyhanni-9cfdf252304e3fe270bd84ddcae292273a9927aa.tar.bz2 skyhanni-9cfdf252304e3fe270bd84ddcae292273a9927aa.zip | |
SkyHanni's own /wiki command logic now works better in SkyBlock Level guide and allows to change weather to use official Hypixel Wiki or the older Fandom Wiki. #831
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 9ee2c42e8..9c4116da4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -369,6 +369,33 @@ object LorenzUtils { Minecraft.getMinecraft().thePlayer.addChatMessage(text) } + /** + * Sends a message to the user that they can click and run a command + * @param message The message to be sent + * @param url The url to be opened + * @param autoOpen Automatically opens the url as well as sending the clickable link message + * @param hover The message to be shown when the message is hovered + * @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 clickableLinkChat( + message: String, + url: String, + hover: String = "§eOpen $url", + autoOpen: Boolean = false, + prefix: Boolean = true, + prefixColor: String = "§e" + ) { + val msgPrefix = if (prefix) prefixColor + CHAT_PREFIX else "" + val text = ChatComponentText(msgPrefix + message) + text.chatStyle.chatClickEvent = ClickEvent(ClickEvent.Action.OPEN_URL, url) + text.chatStyle.chatHoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("$prefixColor$hover")) + Minecraft.getMinecraft().thePlayer.addChatMessage(text) + if (autoOpen) OSUtils.openBrowser(url) + } + fun <K, V> Map<K, V>.moveEntryToTop(matcher: (Map.Entry<K, V>) -> Boolean): Map<K, V> { val entry = entries.find(matcher) if (entry != null) { |
