diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-09-05 21:24:24 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-09-05 21:24:24 +0200 |
| commit | 3a9f1b393cb8a6bdba2057c6bbd88ef2636f443e (patch) | |
| tree | edc9fa2d255e9624bd35f983c241374b4fe3f83e /src/main/kotlin | |
| parent | 88eff36d950ad34fd9450273d991d2b292eabf1e (diff) | |
| download | Firmament-3a9f1b393cb8a6bdba2057c6bbd88ef2636f443e.tar.gz Firmament-3a9f1b393cb8a6bdba2057c6bbd88ef2636f443e.tar.bz2 Firmament-3a9f1b393cb8a6bdba2057c6bbd88ef2636f443e.zip | |
feat: show bazaar order size / sack count for stack prices
Diffstat (limited to 'src/main/kotlin')
| -rw-r--r-- | src/main/kotlin/features/inventory/PriceData.kt | 3 | ||||
| -rw-r--r-- | src/main/kotlin/util/SkyblockId.kt | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main/kotlin/features/inventory/PriceData.kt b/src/main/kotlin/features/inventory/PriceData.kt index 241fb43..32e8a1f 100644 --- a/src/main/kotlin/features/inventory/PriceData.kt +++ b/src/main/kotlin/features/inventory/PriceData.kt @@ -12,6 +12,7 @@ import moe.nea.firmament.util.FirmFormatters.formatCommas import moe.nea.firmament.util.asBazaarStock import moe.nea.firmament.util.bold import moe.nea.firmament.util.darkGrey +import moe.nea.firmament.util.getLogicalStackSize import moe.nea.firmament.util.gold import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.tr @@ -64,7 +65,7 @@ object PriceData : FirmamentFeature { if (!TConfig.tooltipEnabled) return if (TConfig.enableKeybinding.isBound && !TConfig.enableKeybinding.isPressed()) return val sbId = it.stack.skyBlockId - val stackSize = it.stack.count + val stackSize = it.stack.getLogicalStackSize() val isShowingStack = TConfig.stackSizeKey.isPressed() val multiplier = if (isShowingStack) stackSize else 1 val multiplierText = diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt index 03b8bf4..2a0c477 100644 --- a/src/main/kotlin/util/SkyblockId.kt +++ b/src/main/kotlin/util/SkyblockId.kt @@ -33,6 +33,7 @@ import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.repo.set import moe.nea.firmament.util.collections.WeakCache import moe.nea.firmament.util.json.DashlessUUIDSerializer +import moe.nea.firmament.util.mc.loreAccordingToNbt /** * A SkyBlock item id, as used by the NEU repo. @@ -204,6 +205,19 @@ fun ItemStack.setSkyBlockId(skyblockId: SkyblockId): ItemStack { return this } +private val STORED_REGEX = "Stored: ($SHORT_NUMBER_FORMAT)/.+".toPattern() +private val AMOUNT_REGEX = "(?:Offer amount|Amount|Order amount): ($SHORT_NUMBER_FORMAT)x".toPattern() +fun ItemStack.getLogicalStackSize(): Long { + return loreAccordingToNbt.firstNotNullOfOrNull { + val string = it.unformattedString + STORED_REGEX.useMatch(string) { + parseShortNumber(group(1)).toLong() + } ?: AMOUNT_REGEX.useMatch(string) { + parseShortNumber(group(1)).toLong() + } + } ?: count.toLong() +} + val ItemStack.skyBlockId: SkyblockId? get() { return when (val id = extraAttributes.getString("id").getOrNull()) { |
