From 6d97ffcc063200af09226a8c8dd9b9455dabeeb6 Mon Sep 17 00:00:00 2001 From: Mikecraft1224 Date: Sat, 18 May 2024 03:09:53 +0200 Subject: [PATCH] sorted code a bit --- .../skyhanni/features/misc/ReplaceRomanNumerals.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 c57697257ca7..2bbc89172895 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -21,7 +21,13 @@ 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 + private fun String.isSelectOption(): Boolean = isSelectOptionPattern.matches(this) + private val isSelectOptionPattern by patternGroup.pattern( + "string.isselectoption", + "(§eSelect an option: .*)|(§e\\[NPC] .+)" + ) + + // TODO: Remove after pr 1717 is ready and switch to ItemHoverEvent @SubscribeEvent(priority = EventPriority.LOWEST) fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return @@ -49,12 +55,6 @@ class ReplaceRomanNumerals { event.applyIfPossible { it.transformLine() } } - private fun String.isSelectOption(): Boolean = isSelectOptionPattern.matches(this) - private val isSelectOptionPattern by patternGroup.pattern( - "string.isselectoption", - "(§eSelect an option: .*)|(§e\\[NPC] .+)" - ) - private fun String.transformLine() = splitRegex.findAll(this).map { it.value }.joinToString("") { it.takeIf { it.isValidRomanNumeral() && it.removeFormatting().romanToDecimal() != 2000 }?.coloredRomanToDecimal() ?: it }