From 7dc53e46d9816799d713a52015a986291c24f84b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 21 Feb 2023 11:58:39 +0100 Subject: Fixed roman numbers check --- .../at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt | 5 +++-- src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt index 3fe03fe3b..1c6efdc1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern @@ -25,7 +25,8 @@ class GardenInventoryNumbers { event.stack.getLore() .map { patternTierProgress.matcher(it) } .filter { it.matches() } - .map { it.group(1).romanToDecimal() - 1 } + + .map { it.group(1).romanToDecimalIfNeeded() - 1 } .forEach { event.stackTip = "" + it } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index d8e619d78..6da701b78 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -85,6 +85,8 @@ object NumberUtil { } } + fun String.romanToDecimalIfNeeded() = toIntOrNull() ?: romanToDecimal() + /** * This code was converted to Kotlin and taken under CC BY-SA 3.0 license * @link https://stackoverflow.com/a/9073310 -- cgit