aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt9
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
index d2eba9974..89cac9417 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
@@ -46,7 +46,7 @@ class CaptureFarmingGear {
private val patternGroup = RepoPattern.group("garden.fortuneguide.capture")
private val tierPattern by patternGroup.pattern(
"uniquevisitors.tier",
- "§7Progress to Tier (?<nextTier>\\d+):.*"
+ "§7Progress to Tier (?<nextTier>\\w+):.*"
)
private val tierProgressPattern by patternGroup.pattern(
"uniquevisitors.tierprogress",
@@ -153,7 +153,7 @@ class CaptureFarmingGear {
var tierProgress = -1
for (line in item.getLore()) {
tierPattern.matchMatcher(line) {
- tier = group("nextTier").toInt() - 1
+ tier = group("nextTier").romanToDecimalIfNecessary() - 1
}
tierProgressPattern.matchMatcher(line) {
tierProgress = group("having").toInt()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index 10c2eebfd..50bdd453b 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText
import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiUtilRenderComponents
import net.minecraft.util.ChatComponentText
@@ -24,6 +25,10 @@ object StringUtils {
private val whiteSpaceResetPattern = "^(?:\\s|§r)*|(?:\\s|§r)*$".toPattern()
private val whiteSpacePattern = "^\\s*|\\s*$".toPattern()
private val resetPattern = "(?i)§R".toPattern()
+ private val isRomanPattern by RepoPattern.pattern(
+ "utils.string.isroman",
+ "^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})"
+ )
fun String.trimWhiteSpaceAndResets(): String = whiteSpaceResetPattern.matcher(this).replaceAll("")
fun String.trimWhiteSpace(): String = whiteSpacePattern.matcher(this).replaceAll("")
@@ -290,4 +295,8 @@ object StringUtils {
fun String.allLettersFirstUppercase() = split("_").joinToString(" ") { it.firstLetterUppercase() }
fun String?.equalsIgnoreColor(string: String?) = this?.let { it.removeColor() == string?.removeColor() } ?: false
+
+ fun String.isRoman(): Boolean {
+ return isRomanPattern.matches(this)
+ }
}