feat: Hide dungeon score from item exporter
This commit is contained in:
@@ -18,6 +18,7 @@ import moe.nea.firmament.Firmament
|
|||||||
import moe.nea.firmament.annotations.Subscribe
|
import moe.nea.firmament.annotations.Subscribe
|
||||||
import moe.nea.firmament.events.ClientStartedEvent
|
import moe.nea.firmament.events.ClientStartedEvent
|
||||||
import moe.nea.firmament.features.debug.ExportedTestConstantMeta
|
import moe.nea.firmament.features.debug.ExportedTestConstantMeta
|
||||||
|
import moe.nea.firmament.repo.SBItemStack
|
||||||
import moe.nea.firmament.util.HypixelPetInfo
|
import moe.nea.firmament.util.HypixelPetInfo
|
||||||
import moe.nea.firmament.util.LegacyTagWriter.Companion.toLegacyString
|
import moe.nea.firmament.util.LegacyTagWriter.Companion.toLegacyString
|
||||||
import moe.nea.firmament.util.StringUtil.words
|
import moe.nea.firmament.util.StringUtil.words
|
||||||
@@ -68,6 +69,9 @@ class LegacyItemExporter private constructor(var itemStack: ItemStack) {
|
|||||||
if (rarityIdx >= 0) {
|
if (rarityIdx >= 0) {
|
||||||
lore = lore.subList(0, rarityIdx + 1)
|
lore = lore.subList(0, rarityIdx + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trimStats()
|
||||||
|
|
||||||
deleteLineUntilNextSpace { it.startsWith("Held Item: ") }
|
deleteLineUntilNextSpace { it.startsWith("Held Item: ") }
|
||||||
deleteLineUntilNextSpace { it.startsWith("Progress to Level ") }
|
deleteLineUntilNextSpace { it.startsWith("Progress to Level ") }
|
||||||
deleteLineUntilNextSpace { it.startsWith("MAX 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() {
|
fun collapseWhitespaces() {
|
||||||
lore = (listOf(null as Text?) + lore).zipWithNext()
|
lore = (listOf(null as Text?) + lore).zipWithNext()
|
||||||
.filter { !it.first?.unformattedString.isNullOrBlank() || !it.second?.unformattedString.isNullOrBlank() }
|
.filter { !it.first?.unformattedString.isNullOrBlank() || !it.second?.unformattedString.isNullOrBlank() }
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ data class SBItemStack constructor(
|
|||||||
return segments.joinToString(" ") { it.replaceFirstChar { it.uppercaseChar() } }
|
return segments.joinToString(" ") { it.replaceFirstChar { it.uppercaseChar() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseStatLine(line: Text): StatLine? {
|
fun parseStatLine(line: Text): StatLine? {
|
||||||
val sibs = line.siblings
|
val sibs = line.siblings
|
||||||
val stat = sibs.firstOrNull() ?: return null
|
val stat = sibs.firstOrNull() ?: return null
|
||||||
if (stat.style.color != TextColor.fromFormatting(Formatting.GRAY)) return null
|
if (stat.style.color != TextColor.fromFormatting(Formatting.GRAY)) return null
|
||||||
|
|||||||
Reference in New Issue
Block a user