aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenInventoryNumbers.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt2
2 files changed, 5 insertions, 2 deletions
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