From 95bdc53ff71fee3414486a7f9a497b72983527b5 Mon Sep 17 00:00:00 2001 From: Mikecraft1224 Date: Fri, 10 May 2024 19:13:29 +0200 Subject: [PATCH] Fixed ReplaceRomanNumerals replacing the word "I" in dialogue --- .../hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt | 3 ++- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 2 ++ src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) 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 3a93588b6547..8af6434d29b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -8,6 +8,7 @@ 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.removeColor import net.minecraft.event.ClickEvent @@ -44,7 +45,7 @@ class ReplaceRomanNumerals { @SubscribeEvent fun onSystemMessage(event: SystemMessageEvent) { - if (!isEnabled()) return + if (!isEnabled() || event.message.isNPCDialogue()) return event.applyIfPossible { it.transformLine() } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index c048004f22b6..73dfaf31a75c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -320,6 +320,8 @@ object StringUtils { fun String.isRoman(): Boolean = UtilsPatterns.isRomanPattern.matches(this) + fun String.isNPCDialogue(): Boolean = UtilsPatterns.isNPCDialogue.matches(this) + fun isEmpty(message: String): Boolean = message.removeColor().trimWhiteSpaceAndResets().isEmpty() fun generateRandomId() = UUID.randomUUID().toString() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 989204c0ae9d..c1361388936c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -73,6 +73,10 @@ object UtilsPatterns { "string.chatusername", "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?(?:§\\w\\[\\w.+] )?(?:§\\w)?(?\\w+))(?: (?:§\\w)?\\[.+?])?" ) + val isNPCDialogue by patternGroup.pattern( + "string.isnpcdialogue", + "(§eSelect an option: .*)|(§e\\[NPC] .+)" + ) val isRomanPattern by RepoPattern.pattern( "string.isroman", "^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})"