aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-21 11:58:39 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-21 11:58:39 +0100
commit7dc53e46d9816799d713a52015a986291c24f84b (patch)
tree5fd527ac2533172900560e73605635a60de3976c /src/main
parentcdff2f52c54f05c96b9ca62a536392dd51e49e3f (diff)
downloadskyhanni-7dc53e46d9816799d713a52015a986291c24f84b.tar.gz
skyhanni-7dc53e46d9816799d713a52015a986291c24f84b.tar.bz2
skyhanni-7dc53e46d9816799d713a52015a986291c24f84b.zip
Fixed roman numbers check
Diffstat (limited to 'src/main')
-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