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 | |
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')
9 files changed, 231 insertions, 140 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index ad50e01a0..e4dbdd799 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -242,7 +242,7 @@ import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.CurrentPetDisplay import at.hannibal2.skyhanni.features.misc.CustomTextBox import at.hannibal2.skyhanni.features.misc.ExpOrbsOnGroundHider -import at.hannibal2.skyhanni.features.misc.FandomWikiFromMenus +import at.hannibal2.skyhanni.features.misc.BetterWikiFromMenus import at.hannibal2.skyhanni.features.misc.FixGhostEntities import at.hannibal2.skyhanni.features.misc.FixNEUHeavyPearls import at.hannibal2.skyhanni.features.misc.HideArmor @@ -478,7 +478,7 @@ class SkyHanniMod { loadModule(ItemDisplayOverlayFeatures) loadModule(CurrentPetDisplay()) loadModule(ExpOrbsOnGroundHider()) - loadModule(FandomWikiFromMenus()) + loadModule(BetterWikiFromMenus()) loadModule(DamageIndicatorManager()) loadModule(ItemAbilityCooldown()) loadModule(DungeonHighlightClickedBlocks()) @@ -510,7 +510,7 @@ class SkyHanniMod { loadModule(MinionFeatures()) loadModule(TimeFeatures()) loadModule(RngMeterInventory()) - loadModule(WikiManager()) + loadModule(WikiManager) loadModule(SendCoordinatedCommand()) loadModule(WarpIsCommand()) loadModule(ViewRecipeCommand) diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 771bf7055..e2868a931 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.chat.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil import at.hannibal2.skyhanni.features.commands.PartyCommands +import at.hannibal2.skyhanni.features.commands.WikiManager import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper @@ -237,6 +238,22 @@ object Commands { "shresetseacreaturetracker", "Resets the Sea Creature Tracker" ) { SeaCreatureTracker.resetCommand(it) } + registerCommand( + "shfandomwiki", + "Searches the fandom wiki with SkyHanni's own method." + ) {WikiManager.otherWikiCommands(it, true)} + registerCommand( + "shfandomwikithis", + "Searches the fandom wiki with SkyHanni's own method." + ) {WikiManager.otherWikiCommands(it, true, true)} + registerCommand( + "shofficialwiki", + "Searches the official wiki with SkyHanni's own method." + ) {WikiManager.otherWikiCommands(it, false)} + registerCommand( + "shofficialwikithis", + "Searches the official wiki with SkyHanni's own method." + ) {WikiManager.otherWikiCommands(it, false, true)} registerCommand0("shcalccrop", "Calculate how many crops need to be farmed between different crop milestones.", { FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), false) }, FarmingMilestoneCommand::onComplete) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/commands/BetterWikiCommandConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/commands/BetterWikiCommandConfig.java new file mode 100644 index 000000000..68356dd9e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/commands/BetterWikiCommandConfig.java @@ -0,0 +1,44 @@ +package at.hannibal2.skyhanni.config.features.commands; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import org.lwjgl.input.Keyboard; + +public class BetterWikiCommandConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Improve the functionality of the /wiki command.\nThis is required for all of the below features.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "SkyBlock Guide", desc = "Use SkyHanni's method in the SkyBlock Guide.") // TODO Make this method not suck + @ConfigEditorBoolean + @FeatureToggle + public boolean sbGuide = false; + + @Expose + @ConfigOption(name = "Use Fandom Wiki", desc = "Use Fandom Wiki (§ehypixel-skyblock.fandom.com§7) instead of the Hypixel wiki (§ewiki.hypixel.net§7) in most wiki-related chat messages.") + @ConfigEditorBoolean + @FeatureToggle + public boolean useFandom = false; + + @Expose + @ConfigOption(name = "Auto Open", desc = "Directly opens the Wiki when running the command instead of having to click a message in chat.") + @ConfigEditorBoolean + public boolean autoOpenWiki = false; + + @Expose + @ConfigOption(name = "Open from Menus", desc = "Directly opens the Wiki from menus instead of having to click a message in chat.") + @ConfigEditorBoolean + public boolean menuOpenWiki = false; + + @Expose + @ConfigOption(name = "Fandom Wiki Key", desc = "Search for an item on Wiki with this keybind.\n§4For optimal experiences, do §lNOT§r §4bind this to a mouse button.") + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) + public int wikiKeybind = Keyboard.KEY_NONE; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java index 4003cfb99..01f831246 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/commands/CommandsConfig.java @@ -13,10 +13,10 @@ public class CommandsConfig { @Expose public TabCompleteConfig tabComplete = new TabCompleteConfig(); - @ConfigOption(name = "Fandom Wiki for §e/wiki", desc = "") + @ConfigOption(name = "Better §e/wiki", desc = "") @Accordion @Expose - public FandomWikiCommandConfig fandomWiki = new FandomWikiCommandConfig(); + public BetterWikiCommandConfig betterWiki = new BetterWikiCommandConfig(); @ConfigOption(name = "Party Commands", desc = "Shortens party commands and allows tab-completing for them. " + "\n§eCommands: /pt /pp /pko /pk /pd §7SkyBlock command §e/pt §7to check the play time still works.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/commands/FandomWikiCommandConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/commands/FandomWikiCommandConfig.java deleted file mode 100644 index c8a25a204..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/commands/FandomWikiCommandConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package at.hannibal2.skyhanni.config.features.commands; - -import at.hannibal2.skyhanni.config.FeatureToggle; -import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; -import io.github.moulberry.moulconfig.annotations.ConfigOption; -import org.lwjgl.input.Keyboard; - -public class FandomWikiCommandConfig { - - @Expose - @ConfigOption(name = "Enabled", desc = "Use Fandom Wiki (§ehypixel-skyblock.fandom.com§7) instead of the Hypixel wiki (§ewiki.hypixel.net§7) in most wiki-related chat messages.") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = false; - - @Expose - @ConfigOption(name = "Skip Chat", desc = "Directly opens the Fandom Wiki instead of sending the §e\"Click to search for this thing on the Fandom Wiki\"§7 message beforehand.") - @ConfigEditorBoolean - public boolean skipWikiChat = false; - - @Expose - @ConfigOption(name = "Fandom Wiki Key", desc = "Search for an item on Fandom Wiki with this keybind.\n§4For optimal experiences, do §lNOT§r §4bind this to a mouse button.") - @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) - public int fandomWikiKeybind = Keyboard.KEY_NONE; -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt index b3bdbe42c..c1aab3a1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt @@ -9,21 +9,20 @@ import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.item.ItemStack import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.net.URLEncoder -class WikiManager { +object WikiManager { + private const val OFFICIAL_URL_PREFIX = "https://wiki.hypixel.net/" + private const val OFFICIAL_SEARCH_PREFIX = "index.php?search=" + private const val FANDOM_URL_PREFIX = "https://hypixel-skyblock.fandom.com/wiki/" + private const val FANDOM_SEARCH_PREFIX = "Special:Search?query=" - private val config get() = SkyHanniMod.feature.commands.fandomWiki - - companion object { - private val urlPrefix = "https://hypixel-skyblock.fandom.com/wiki/" - val urlSearchPrefix = "${urlPrefix}Special:Search?query=" - } + private val config get() = SkyHanniMod.feature.commands.betterWiki @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { @@ -34,23 +33,26 @@ class WikiManager { fun onMessageSendToServer(event: MessageSendToServerEvent) { if (!LorenzUtils.inSkyBlock) return if (!isEnabled()) return - val message = event.message.lowercase() if (!(message.startsWith("/wiki"))) return + event.isCanceled = true if (message == "/wiki") { - LorenzUtils.chat("Opening the Fandom Wiki..") - OSUtils.openBrowser("${urlPrefix}Hypixel_SkyBlock_Wiki") - } else if (message.startsWith("/wiki ") || message == ("/wikithis")) { //conditional to see if we need Special:Search page - if (message == ("/wikithis")) { - val itemInHand = InventoryUtils.getItemInHand() ?: return - wikiTheItem(itemInHand) - } else { - val search = event.message.split("/wiki ").last() - LorenzUtils.chat("Searching the Fandom Wiki for §a$search") - val wikiUrlCustom = "$urlSearchPrefix$search&scope=internal" - OSUtils.openBrowser(wikiUrlCustom.replace(' ', '+')) + sendWikiMessage() + return + } + if (message.startsWith("/wiki ")) { + val search = event.message.drop("/wiki ".length) + sendWikiMessage(search) + return + } + if (message == ("/wikithis")) { + val itemInHand = InventoryUtils.getItemInHand() ?: run { + LorenzUtils.chat("§cYou must be holding an item to use this command!") + return } + wikiTheItem(itemInHand, config.autoOpenWiki) + return } } @@ -61,17 +63,65 @@ class WikiManager { if (NEUItems.neuHasFocus()) return //because good heavens if this worked on neuitems... val stack = gui.slotUnderMouse?.stack ?: return - if (!config.fandomWikiKeybind.isKeyHeld()) return - wikiTheItem(stack) + if (!config.wikiKeybind.isKeyHeld()) return + wikiTheItem(stack, config.menuOpenWiki) } - private fun wikiTheItem(item: ItemStack) { - val itemDisplayName = (item.nameWithEnchantment ?: return).replace("§a✔ ", "").replace("§c✖ ", "") + private fun wikiTheItem(item: ItemStack, autoOpen: Boolean, useFandom: Boolean = config.useFandom) { + val itemDisplayName = + (item.nameWithEnchantment ?: return).replace("§a✔ ", "").replace("§c✖ ", "") val internalName = item.getInternalName().asString() - LorenzUtils.chat("Searching the Fandom Wiki for §a$itemDisplayName") - val wikiUrlSearch = if (internalName != "NONE") "$urlSearchPrefix$internalName&scope=internal" - else "$urlSearchPrefix${itemDisplayName.removeColor()}&scope=internal" - OSUtils.openBrowser(wikiUrlSearch.replace(' ', '+')) + val wikiUrlSearch = if (internalName != "NONE") internalName else itemDisplayName.removeColor() + + sendWikiMessage(wikiUrlSearch, itemDisplayName.removeColor(), autoOpen, useFandom) + } + + fun otherWikiCommands(args: Array<String>, useFandom: Boolean, wikithis: Boolean = false) { + if (wikithis && !LorenzUtils.inSkyBlock) { + LorenzUtils.chat("§cYou must be in SkyBlock to do this!") + return + } + + var search = "" + for (arg in args) search = "$search${arg}" + + if (wikithis) { + val itemInHand = InventoryUtils.getItemInHand() ?: run { + LorenzUtils.chat("§cYou must be holding an item to use this command!") + return + } + wikiTheItem(itemInHand, false, useFandom = useFandom) + return + } + if (search == "") { + sendWikiMessage(useFandom = useFandom) + return + } + sendWikiMessage(search, useFandom = useFandom) + } + + fun sendWikiMessage( + search: String = "", displaySearch: String = search, + autoOpen: Boolean = config.autoOpenWiki, useFandom: Boolean = config.useFandom + ) { + val wiki = if (useFandom) "SkyBlock Fandom Wiki" else "Official SkyBlock Wiki" + val urlPrefix = if (useFandom) FANDOM_URL_PREFIX else OFFICIAL_URL_PREFIX + if (search == "") { + LorenzUtils.clickableLinkChat( + "§7Click §e§lHERE §7to visit the §6$wiki§7!", urlPrefix, "§7The $wiki!" + ) + return + } + + val urlSearchPrefix = if (useFandom) "$urlPrefix$FANDOM_SEARCH_PREFIX" else "$urlPrefix$OFFICIAL_SEARCH_PREFIX" + val searchUrl = "$urlSearchPrefix${URLEncoder.encode(search, "UTF-8")}&scope=internal" + + LorenzUtils.clickableLinkChat( + "§7Click §e§lHERE §7to find §a$displaySearch §7on the §6$wiki§7!", + searchUrl, + "§7View §a$displaySearch §7on the §6$wiki§7!", + autoOpen + ) } private fun isEnabled() = config.enabled diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt new file mode 100644 index 000000000..a0ead6b7c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt @@ -0,0 +1,60 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.features.commands.WikiManager +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import io.github.moulberry.notenoughupdates.events.SlotClickEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class BetterWikiFromMenus { + + private val config get() = SkyHanniMod.feature.commands.betterWiki + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(6, "fandomWiki", "commands.fandomWiki") + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onSlotClick(event: SlotClickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!isEnabled()) return + + val chestName = InventoryUtils.openInventoryName() + + if (chestName.isEmpty()) return + + val itemClickedStack = event.slot.stack ?: return + val itemClickedName = itemClickedStack.displayName + + val isWiki = event.slotId == 11 && itemClickedName.contains("Wiki Command") + val isWikithis = event.slotId == 15 && itemClickedName.contains("Wikithis Command") + val inBiblioInventory = chestName == "SkyBlock Wiki" && (isWiki || isWikithis) + val inSBGuideInventory = (itemClickedStack.getLore().let { it.any { line -> line == "§7§eClick to view on the SkyBlock Wiki!" } }) + + if (inBiblioInventory) { + if (isWiki) { + WikiManager.sendWikiMessage(useFandom = true) + return + } + + if (isWikithis) { + WikiManager.otherWikiCommands(arrayOf(""), true, true) + return + } + } + + if (inSBGuideInventory && config.sbGuide) { + val wikiSearch = itemClickedName.removeColor().replace("✔ ", "").replace("✖ ", "") + WikiManager.sendWikiMessage(wikiSearch, autoOpen = config.menuOpenWiki) + event.isCanceled = true + } + } + + private fun isEnabled() = config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt deleted file mode 100644 index dbc3725bf..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FandomWikiFromMenus.kt +++ /dev/null @@ -1,80 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.features.commands.WikiManager -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.OSUtils -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import io.github.moulberry.notenoughupdates.events.SlotClickEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class FandomWikiFromMenus { - - private val config get() = SkyHanniMod.feature.commands.fandomWiki - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(6, "fandomWiki", "commands.fandomWiki") - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onSlotClick(event: SlotClickEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!isEnabled()) return - val chestName = InventoryUtils.openInventoryName() - - if (chestName.isEmpty()) return - - val itemClickedStack = event.slot.stack ?: return - val itemClickedName = itemClickedStack.displayName - val itemInHand = InventoryUtils.getItemInHand() ?: return - val itemInHandName = itemInHand.nameWithEnchantment ?: return - - val wikiDisplayName: String - val wikiInternalName: String - - val inWikiInventory = // TODO better name for this inventory - event.slotId == 11 && itemClickedName.contains("Wiki Command") && chestName.contains("Wiki") - if ((itemInHandName == "") || inWikiInventory) { - LorenzUtils.clickableChat("Click here to visit the Hypixel Skyblock Fandom Wiki!", "wiki") - return - } - - val inOtherWikiInventory = // TODO better name for this inventory - event.slotId == 15 && itemClickedName.contains("Wikithis Command") && chestName.contains("Wiki") - if (inOtherWikiInventory) { - wikiDisplayName = itemInHandName - val internalName = itemInHand.getInternalName().asString() - wikiInternalName = internalName - } else { - //.lowercase() to match "Wiki!" and ".*wiki.*" lore lines in one fell swoop - val inThirdWikiInventory = // TODO better name for this inventory - (itemClickedStack.getLore() - .let { it.any { line -> line == "§7§eClick to view on the SkyBlock" } && it.last() == "§eWiki!" }) - if (inThirdWikiInventory) { - wikiDisplayName = itemClickedName.removeColor().replace("✔ ", "").replace("✖ ", "") - wikiInternalName = wikiDisplayName - } else return - } - - if (!config.skipWikiChat) { - LorenzUtils.clickableChat( - "Click here to search for $wikiDisplayName §eon the Hypixel Skyblock Fandom Wiki!", - "wiki $wikiInternalName" - ) - } else { - LorenzUtils.chat("Searching the Fandom Wiki for §a$wikiDisplayName") - val wikiUrlCustom = "${WikiManager.urlSearchPrefix}$wikiInternalName&scope=internal" - OSUtils.openBrowser(wikiUrlCustom.replace(' ', '+')) - } - event.isCanceled = true - } - - private fun isEnabled() = config.enabled -} 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) { |