From 9cfdf252304e3fe270bd84ddcae292273a9927aa Mon Sep 17 00:00:00 2001 From: Obsidian <108832807+Obsidianninja11@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:40:02 -0900 Subject: 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 --- .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils') 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 Map.moveEntryToTop(matcher: (Map.Entry) -> Boolean): Map { val entry = entries.find(matcher) if (entry != null) { -- cgit