From 791f12f2ee1ad147ddb12abde5a74bd3b0f4bdce Mon Sep 17 00:00:00 2001 From: martimavocado <39881008+martimavocado@users.noreply.github.com> Date: Sat, 10 Feb 2024 00:17:57 +0000 Subject: Fixed opening visitor Milestones menu not loading visitor amount for /ff. #988 --- src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt') 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) + } } -- cgit