feat: Hide dungeon score from item exporter

This commit is contained in:
Linnea Gräf
2025-06-22 19:50:31 +02:00
parent 9bdbf28a58
commit 05ca14b623
2 changed files with 23 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ import moe.nea.firmament.Firmament
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ClientStartedEvent
import moe.nea.firmament.features.debug.ExportedTestConstantMeta
import moe.nea.firmament.repo.SBItemStack
import moe.nea.firmament.util.HypixelPetInfo
import moe.nea.firmament.util.LegacyTagWriter.Companion.toLegacyString
import moe.nea.firmament.util.StringUtil.words
@@ -68,6 +69,9 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
if (rarityIdx >= 0) {
lore = lore.subList(0, rarityIdx + 1)
}
trimStats()
deleteLineUntilNextSpace { it.startsWith("Held Item: ") }
deleteLineUntilNextSpace { it.startsWith("Progress to Level ") }
deleteLineUntilNextSpace { it.startsWith("MAX LEVEL") }
@@ -80,6 +84,24 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
}
}
private fun trimStats() {
val lore = this.lore.toMutableList()
for (index in lore.indices) {
val value = lore[index]
val statLine = SBItemStack.parseStatLine(value)
if (statLine == null) break
val v = value.copy()
require(value.directLiteralStringContent == "")
v.siblings.removeIf { it.directLiteralStringContent!!.contains("(") }
val last = v.siblings.last()
v.siblings[v.siblings.lastIndex] =
Text.literal(last.directLiteralStringContent!!.trimEnd())
.setStyle(last.style)
lore[index] = v
}
this.lore = lore
}
fun collapseWhitespaces() {
lore = (listOf(null as Text?) + lore).zipWithNext()
.filter { !it.first?.unformattedString.isNullOrBlank() || !it.second?.unformattedString.isNullOrBlank() }

View File

@@ -263,7 +263,7 @@ data class SBItemStack constructor(
return segments.joinToString(" ") { it.replaceFirstChar { it.uppercaseChar() } }
}
private fun parseStatLine(line: Text): StatLine? {
fun parseStatLine(line: Text): StatLine? {
val sibs = line.siblings
val stat = sibs.firstOrNull() ?: return null
if (stat.style.color != TextColor.fromFormatting(Formatting.GRAY)) return null