diff --git a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt index 2b3041d62f88..02baee36d674 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt @@ -3,4 +3,4 @@ package at.hannibal2.skyhanni.events.item import at.hannibal2.skyhanni.events.LorenzEvent import net.minecraft.item.ItemStack -class ItemHoverEvent(val itemStack: ItemStack, val toolTip: List) : LorenzEvent() +class ItemHoverEvent(val itemStack: ItemStack, val toolTip: MutableList) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt index 18c2b4e66471..87d45775f00c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -4,17 +4,16 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.events.ChatHoverEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.events.item.ItemHoverEvent import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible -import at.hannibal2.skyhanni.utils.StringUtils.isNPCDialogue import at.hannibal2.skyhanni.utils.StringUtils.isRoman +import at.hannibal2.skyhanni.utils.StringUtils.isSelectOption import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent import net.minecraft.util.ChatComponentText -import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -22,6 +21,7 @@ class ReplaceRomanNumerals { // Using toRegex here since toPattern doesn't seem to provide the necessary functionality private val splitRegex = "((§\\w)|(\\s+)|(\\W))+|(\\w*)".toRegex() + // Remove after pr 1717 is ready and switch to ItemHoverEvent @SubscribeEvent(priority = EventPriority.LOWEST) fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return @@ -29,6 +29,13 @@ class ReplaceRomanNumerals { event.toolTip.replaceAll { it.transformLine() } } +// @SubscribeEvent(priority = EventPriority.LOWEST) +// fun onItemHover(event: ItemHoverEvent) { +// if (!isEnabled()) return +// +// event.toolTip.replaceAll { it.transformLine() } +// } + @SubscribeEvent(priority = EventPriority.LOWEST) fun onChatHover(event: ChatHoverEvent) { if (event.getHoverEvent().action != HoverEvent.Action.SHOW_TEXT) return @@ -45,12 +52,12 @@ class ReplaceRomanNumerals { @SubscribeEvent fun onSystemMessage(event: SystemMessageEvent) { - if (!isEnabled() || event.message.isNPCDialogue()) return + if (!isEnabled() || event.message.isSelectOption()) return event.applyIfPossible { it.transformLine() } } private fun String.transformLine() = splitRegex.findAll(this).map { it.value }.joinToString("") { - it.takeIf { it.isValidRomanNumeral() && it.removeFormatting().romanToDecimal() < 1000 }?.coloredRomanToDecimal() ?: it + it.takeIf { it.isValidRomanNumeral() && it.removeFormatting().romanToDecimal() != 2000 }?.coloredRomanToDecimal() ?: it } private fun String.removeFormatting() = removeColor().replace(",", "") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 73dfaf31a75c..0a0d5c244ac6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -320,7 +320,7 @@ object StringUtils { fun String.isRoman(): Boolean = UtilsPatterns.isRomanPattern.matches(this) - fun String.isNPCDialogue(): Boolean = UtilsPatterns.isNPCDialogue.matches(this) + fun String.isSelectOption(): Boolean = UtilsPatterns.isSelectOption.matches(this) fun isEmpty(message: String): Boolean = message.removeColor().trimWhiteSpaceAndResets().isEmpty() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index c1361388936c..827a4b0a6825 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -73,8 +73,8 @@ object UtilsPatterns { "string.chatusername", "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?(?:§\\w\\[\\w.+] )?(?:§\\w)?(?\\w+))(?: (?:§\\w)?\\[.+?])?" ) - val isNPCDialogue by patternGroup.pattern( - "string.isnpcdialogue", + val isSelectOption by patternGroup.pattern( + "string.isselectoption", "(§eSelect an option: .*)|(§e\\[NPC] .+)" ) val isRomanPattern by RepoPattern.pattern(