Skip to content

Commit

Permalink
Fixed ReplaceRomanNumerals replacing the word "I" in dialogue
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikecraft1224 committed May 10, 2024
1 parent e24f16d commit 95bdc53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,7 +45,7 @@ class ReplaceRomanNumerals {

@SubscribeEvent
fun onSystemMessage(event: SystemMessageEvent) {
if (!isEnabled()) return
if (!isEnabled() || event.message.isNPCDialogue()) return
event.applyIfPossible { it.transformLine() }
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ object UtilsPatterns {
"string.chatusername",
"^(?:§\\w\\\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?<rankedName>(?:§\\w\\[\\w.+] )?(?:§\\w)?(?<username>\\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})"
Expand Down

0 comments on commit 95bdc53

Please sign in to comment.