diff options
author | martimavocado <39881008+martimavocado@users.noreply.github.com> | 2024-02-10 00:17:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 01:17:57 +0100 |
commit | 791f12f2ee1ad147ddb12abde5a74bd3b0f4bdce (patch) | |
tree | 8354f1c6277170d49418a7e36bdfb21b698dd0aa /src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | |
parent | fb7d2d3af38f5cee2b2029bc93c49943a1b7ae35 (diff) | |
download | skyhanni-791f12f2ee1ad147ddb12abde5a74bd3b0f4bdce.tar.gz skyhanni-791f12f2ee1ad147ddb12abde5a74bd3b0f4bdce.tar.bz2 skyhanni-791f12f2ee1ad147ddb12abde5a74bd3b0f4bdce.zip |
Fixed opening visitor Milestones menu not loading visitor amount for /ff. #988
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 9 |
1 files changed, 9 insertions, 0 deletions
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) + } } |