From d4510fa75a26cdadb9cdeedfd29c89201f0b8fce Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:32:35 +0100 Subject: [PATCH] Improvement + Backend: Roman Allow List (#3113) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/misc/MiscConfig.java | 2 +- .../elements/ScoreboardElementSlayer.kt | 3 +- .../features/misc/ReplaceRomanNumerals.kt | 133 +++++++++++------- .../items/EstimatedItemValueCalculator.kt | 4 +- .../misc/items/enchants/EnchantParser.kt | 25 ++-- .../features/slayer/SlayerProfitTracker.kt | 31 ++-- .../features/slayer/SlayerRngMeterDisplay.kt | 2 - .../at/hannibal2/skyhanni/utils/ItemUtils.kt | 19 ++- 8 files changed, 132 insertions(+), 87 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 1e3f393a9a1d..cf75a3411bc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -305,7 +305,7 @@ public class MiscConfig { @ConfigOption(name = "Replace Roman Numerals", desc = "Replace Roman Numerals with Arabic Numerals on any item.") @ConfigEditorBoolean @FeatureToggle - public boolean replaceRomanNumerals = false; + public Property replaceRomanNumerals = Property.of(false); @Expose @ConfigOption(name = "Thunder Bottle", desc = "Show a notification when your Thunder Bottle is fully charged.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt index b2f10b412494..de101f453594 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig +import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals // internal // scoreboard update event @@ -9,7 +10,7 @@ object ScoreboardElementSlayer : ScoreboardElement() { override fun getDisplay() = buildList { if (!SlayerAPI.hasActiveSlayerQuest()) return@buildList add("Slayer Quest") - add(SlayerAPI.latestSlayerCategory) + add(ReplaceRomanNumerals.replaceLine(SlayerAPI.latestSlayerCategory)) add(SlayerAPI.latestSlayerProgress) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt index be1fcd7994de..8f59492a758f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -4,54 +4,65 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.events.ChatHoverEvent -import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal -import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher +import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible import at.hannibal2.skyhanni.utils.StringUtils.isRoman import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TimeLimitedCache import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.event.HoverEvent import net.minecraft.util.ChatComponentText +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds @SkyHanniModule object ReplaceRomanNumerals { - private val patternGroup = RepoPattern.group("replace.roman") - - /** - * REGEX-TEST: §9Dedication IV - * REGEX-FAIL: §cD§6y§ee§as - */ - private val findRomanNumeralPattern by patternGroup.pattern( - "findroman", - "[ ➜](?=[MDCLXVI])(?M*(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3}))(?.?)" - ) - - /** - * REGEX-TEST: K - */ - private val isWordPattern by patternGroup.pattern( - "findword", - "^[\\w-']" + // Using toRegex here since toPattern doesn't seem to provide the necessary functionality + private val splitRegex = "((§\\w)|(\\s+)|(\\W))+|(\\w*)".toRegex() + private val cachedStrings = TimeLimitedCache(5.seconds) + + private val patternGroup = RepoPattern.group("replace.roman.numerals") + + @Suppress("MaxLineLength") + private val allowedPatterns by patternGroup.list( + "allowed.patterns", + "§o§a(?:Combat|Farming|Fishing|Mining|Foraging|Enchanting|Alchemy|Carpentry|Runecrafting|Taming|Social|)( Level)? (?[IVXLCDM]+)§r", + "(?:§5§o)?§7Progress to (?:Collection|Level|Tier|Floor|Milestone|Chocolate Factory) (?[IVXLCDM]+): §.(?:.*)%", + "§5§o §e(?:\\w+) (?[IVXLCDM]+)", + "(?:§.)*Abiphone (?[IVXLCDM]+) .*", + "§o§a§a(?:§c§lMM§c )?The Catacombs §8- §eFloor (?[IVXLCDM]+)§r", + ".*Extra Farming Fortune (?[IVXLCDM]+)", + ".*(?:Collection|Level|Tier|Floor|Milestone) (?[IVXLCDM]+)(?: ?§(?:7|r).*)?", + "(?:§5§o§a ✔|§5§o§c ✖) §.* (?[IVXLCDM]+)", + "§o§a✔ §.* (?[IVXLCDM]+)§r", + "§5§o§7Purchase §a.* (?[IVXLCDM]+) §7.*", + "§5§o(?:§7)§.(?[IVXLCDM]+).*", + ".*Heart of the Mountain (?[IVXLCDM]+) ?.*" ) /** - * REGEX-TEST: ➜ + * REGEX-TEST: §eSelect an option: §r§a[§aOk, then what?§a] */ - private val allowedCharactersAfter by patternGroup.pattern( - "allowedcharactersafter", - "[➜):]?" + private val isSelectOptionPattern by patternGroup.pattern( + "string.isselectoption", + "§eSelect an option: .*", ) - @HandleEvent(priority = HandleEvent.LOWEST) - fun onTooltip(event: ItemHoverEvent) { + // TODO: Remove after pr 1717 is ready and switch to ItemHoverEvent + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return - event.toolTip.replaceAll { it.transformLine() } + event.toolTip.replaceAll { it.tryReplace() } } @HandleEvent(priority = HandleEvent.LOWEST) @@ -60,7 +71,7 @@ object ReplaceRomanNumerals { if (!isEnabled()) return val lore = event.getHoverEvent().value.formattedText.split("\n").toMutableList() - lore.replaceAll { it.transformLine() } + lore.replaceAll { it.tryReplace() } val chatComponentText = ChatComponentText(lore.joinToString("\n")) val hoverEvent = HoverEvent(event.component.chatStyle.chatHoverEvent?.action, chatComponentText) @@ -70,38 +81,58 @@ object ReplaceRomanNumerals { @HandleEvent fun onSystemMessage(event: SystemMessageEvent) { - if (!isEnabled()) return - event.applyIfPossible { it.transformLine() } + if (!isEnabled() || event.message.isSelectOption()) return + event.applyIfPossible { it.tryReplace() } } - /** - * Transforms a line with a roman numeral to a line with a decimal numeral. - * Override block one is to be used for tablist or other places where there is no need to check for normal text containing - * the word "I". - * - * Currently not replaced: - * - "§7Bonzo I Reward:" in the collection rewards when hovering on the collection - */ - private fun String.transformLine(overrideBlockOne: Boolean = false): String { - val (romanNumeral, rest) = findRomanNumeralPattern.findMatcher(this.removeFormatting()) { - group("roman") to group("extra") - } ?: return this + @SubscribeEvent(priority = EventPriority.LOW) + fun onRepoReload(event: RepositoryReloadEvent) { + cachedStrings.clear() + } - if (romanNumeral.isNullOrEmpty() || !romanNumeral.isRoman() || isWordPattern.matches(rest)) { - return recursiveSplit(romanNumeral) - } + private fun String.isSelectOption(): Boolean = isSelectOptionPattern.matches(this) - val parsedRomanNumeral = romanNumeral.romanToDecimal() + private fun String.tryReplace(): String = cachedStrings.getOrPut(this) { + if (allowedPatterns.matches(this)) replace() else this + } + + fun replaceLine(line: String): String { + if (!isEnabled()) return line - return takeIf { parsedRomanNumeral != 1 || overrideBlockOne || rest.isEmpty() || allowedCharactersAfter.matches(rest) } - ?.replaceFirst(romanNumeral, parsedRomanNumeral.toString())?.transformLine() - ?: recursiveSplit(romanNumeral) + return cachedStrings.getOrPut(line) { + line.replace() + } } - private fun String.recursiveSplit(romanNumeral: String) = - this.split(romanNumeral, limit = 2).let { it[0] + romanNumeral + it[1].transformLine() } + private fun String.replace() = splitRegex.findAll(this).map { it.value }.joinToString("") { + it.takeIf { it.isValidRomanNumeral() && it.removeFormatting().romanToDecimal() != 2000 }?.coloredRomanToDecimal() ?: it + } private fun String.removeFormatting() = removeColor().replace(",", "") - private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.replaceRomanNumerals + private fun String.isValidRomanNumeral() = removeFormatting().let { it.isRoman() && it.isNotEmpty() } + + private fun String.coloredRomanToDecimal() = removeFormatting().let { replace(it, it.romanToDecimal().toString()) } + + private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.replaceRomanNumerals.get() + + init { + RecalculatingValue + } + + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Replace Roman Numerals") + event.addIrrelevant { + val map = cachedStrings.toMap() + add("cachedStrings: (${map.size})") + for ((original, changed) in map) { + if (original == changed) { + add("unchanged: '$original'") + } else { + add("'$original' -> '$changed'") + } + } + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index c8fc7aed0c17..c49e56d7e990 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -19,7 +19,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getAttributeFromShard import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.getReadableNBTDump import at.hannibal2.skyhanni.utils.ItemUtils.isRune import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -777,10 +776,9 @@ object EstimatedItemValueCalculator { if (rawName in tieredEnchants) level = 1 val enchantmentName = "$rawName;$level".uppercase().toInternalName() - val itemStack = enchantmentName.getItemStackOrNull() ?: continue val singlePrice = enchantmentName.getPriceOrNull(config.priceSource.get()) ?: continue - var name = itemStack.getLore()[0] + var name = enchantmentName.itemName // TODO find a way to use this here "".toInternalName().getPriceName(multiplier) if (multiplier > 1) { name = "§8${multiplier}x $name" diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt index 8c1661739348..6d028f6ecd8b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getExtraAttributes import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -53,6 +53,7 @@ object EnchantParser { "exclusive", "^(?:(?:§.)+[A-Za-z][A-Za-z '-]+ (?:[IVXLCDM]+|[0-9]+)(?:(?:§r)?§9, |\$| §8\\d{1,3}(?:[,.]\\d{1,3})*)[kKmMbB]?)+\$", ) + // Above regex tests apply to this pattern also @Suppress("MaxLineLength") val enchantmentPattern by patternGroup.pattern( @@ -213,7 +214,7 @@ object EnchantParser { "Item has enchants in nbt but none were found?", "item" to currentItem, "loreList" to loreList, - "nbt" to currentItem?.getExtraAttributes() + "nbt" to currentItem?.getExtraAttributes(), ) return } catch (e: ConcurrentModificationException) { @@ -222,7 +223,7 @@ object EnchantParser { "ConcurrentModificationException whilst formatting enchants", "loreList" to loreList, "format" to config.format.get(), - "orderedEnchants" to orderedEnchants.toString() + "orderedEnchants" to orderedEnchants.toString(), ) } @@ -271,22 +272,18 @@ object EnchantParser { private fun orderEnchants(loreList: MutableList) { var lastEnchant: FormattedEnchant? = null + val isRoman = !SkyHanniMod.feature.misc.replaceRomanNumerals.get() + val regex = "[\\d,.kKmMbB]+\$".toRegex() for (i in startEnchant..endEnchant) { val matcher = enchantmentPattern.matcher(loreList[i]) var containsEnchant = false var enchantsOnThisLine = 0 - var isRoman = true while (matcher.find()) { // Pull enchant, enchant level and stacking amount if applicable val enchant = this.enchants.getFromLore(matcher.group("enchant")) - val level = try { - // If one enchant is not a roman numeral we assume all are not roman numerals (idk a situation where this wouldn't be the case) - matcher.group("levelNumeral").toInt().also { isRoman = false } - } catch (e: NumberFormatException) { - matcher.group("levelNumeral").romanToDecimal() - } - val stacking = if (matcher.group("stacking").trimStart().removeColor().matches("[\\d,.kKmMbB]+\$".toRegex())) { + val level = matcher.group("levelNumeral").romanToDecimalIfNecessary() + val stacking = if (matcher.group("stacking").trimStart().removeColor().matches(regex)) { shouldBeSingleColumn = true matcher.group("stacking") } else "empty" @@ -295,9 +292,9 @@ object EnchantParser { lastEnchant = FormattedEnchant(enchant, level, stacking, isRoman) if (!orderedEnchants.add(lastEnchant)) { - for (e: FormattedEnchant in orderedEnchants) { - if (lastEnchant?.let { e.compareTo(it) } == 0) { - lastEnchant = e + for (formattedEnchant: FormattedEnchant in orderedEnchants) { + if (lastEnchant?.let { formattedEnchant.compareTo(it) } == 0) { + lastEnchant = formattedEnchant break } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt index 446b927deea9..0bb83f270d7b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SlayerChangeEvent import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent +import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString @@ -41,7 +42,8 @@ object SlayerProfitTracker { private val config get() = SkyHanniMod.feature.slayer.itemProfitTracker - private var itemLogCategory = "" + private var category = "" + private val categoryName get() = ReplaceRomanNumerals.replaceLine(category) private var baseSlayerType = "" private val trackers = mutableMapOf>() @@ -126,21 +128,21 @@ object SlayerProfitTracker { @HandleEvent fun onSlayerChange(event: SlayerChangeEvent) { val newSlayer = event.newSlayer - itemLogCategory = newSlayer.removeColor() - baseSlayerType = itemLogCategory.substringBeforeLast(" ") + category = newSlayer.removeColor() + baseSlayerType = category.substringBeforeLast(" ") getTracker()?.update() } private fun getTracker(): SkyHanniItemTracker? { - if (itemLogCategory == "") return null + if (category == "") return null - return trackers.getOrPut(itemLogCategory) { + return trackers.getOrPut(category) { val getStorage: (ProfileSpecificStorage) -> Data = { it.slayerProfitData.getOrPut( - itemLogCategory, + category, ) { Data() } } - SkyHanniItemTracker("$itemLogCategory Profit Tracker", { Data() }, getStorage) { drawDisplay(it) } + SkyHanniItemTracker("$categoryName Profit Tracker", { Data() }, getStorage) { drawDisplay(it) } } } @@ -162,7 +164,7 @@ object SlayerProfitTracker { private fun tryAddItem(internalName: NEUInternalName, amount: Int, command: Boolean) { if (!isAllowedItem(internalName) && internalName != NEUInternalName.SKYBLOCK_COIN) { - ChatUtils.debug("Ignored non-slayer item pickup: '$internalName' '$itemLogCategory'") + ChatUtils.debug("Ignored non-slayer item pickup: '$internalName' '$category'") return } @@ -176,7 +178,7 @@ object SlayerProfitTracker { private fun drawDisplay(data: Data) = buildList { val tracker = getTracker() ?: return@buildList - addSearchString("§e§l$itemLogCategory Profit Tracker") + addSearchString("§e§l$categoryName Profit Tracker") var profit = tracker.drawItems(data, { true }, this) val slayerSpawnCost = data.slayerSpawnCost @@ -191,11 +193,14 @@ object SlayerProfitTracker { profit += slayerSpawnCost } - val slayerCompletedCount = data.slayerCompletedCount + val slayerCompletedCount = data.slayerCompletedCount.addSeparators() add( Renderable.hoverTips( - "§7Bosses killed: §e${slayerCompletedCount.addSeparators()}", - listOf("§7You killed the $itemLogCategory boss", "§e${slayerCompletedCount.addSeparators()} §7times."), + "§7Bosses killed: §e$slayerCompletedCount", + listOf( + "§7You killed the $categoryName boss", + "§e$slayerCompletedCount §7times.", + ), ).toSearchable(), ) @@ -248,7 +253,7 @@ object SlayerProfitTracker { fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled fun resetCommand() { - if (itemLogCategory == "") { + if (category == "") { ChatUtils.userError( "No current slayer data found! " + "§eGo to a slayer area and start the specific slayer type you want to reset the data of.", diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index 5427013c9506..45a29e60d6d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -222,8 +222,6 @@ object SlayerRngMeterDisplay { ) { return "" } - val latestSlayerCategory = SlayerAPI.latestSlayerCategory - latestSlayerCategory.endsWith(" I") with(storage) { if (itemGoal == "?") return "§cOpen RNG Meter Inventory!" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 4bb28c0f2dd8..cf0672a09b07 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -1,10 +1,13 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.NotificationManager import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.SkyHanniNotification +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator.getAttributeName import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager @@ -46,6 +49,13 @@ object ItemUtils { private val missingRepoItems = mutableSetOf() private var lastRepoWarning = SimpleTimeMark.farPast() + @HandleEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(SkyHanniMod.feature.misc.replaceRomanNumerals) { + itemNameCache.clear() + } + } + private val SKYBLOCK_MENU by lazy { "SKYBLOCK_MENU".toInternalName() } fun ItemStack.cleanName() = this.displayName.removeColor() @@ -500,10 +510,10 @@ object ItemUtils { // show enchanted book name if (itemStack.getItemCategoryOrNull() == ItemCategory.ENCHANTED_BOOK) { - return itemStack.getLore()[0] + return ReplaceRomanNumerals.replaceLine(itemStack.getLore()[0]) } if (name.endsWith("Enchanted Book Bundle")) { - return name.replace("Enchanted Book", itemStack.getLore()[0].removeColor()) + return name.replace("Enchanted Book", ReplaceRomanNumerals.replaceLine(itemStack.getLore()[0]).removeColor()) } // obfuscated trophy fish @@ -511,6 +521,11 @@ object ItemUtils { return name.replace("§kObfuscated", "Obfuscated") } + // remove roman runic tier + if (isRune()) { + return ReplaceRomanNumerals.replaceLine(name) + } + // hide pet level PetAPI.getCleanName(name)?.let { return "$it Pet"