feat: Make use of bazaar stocks for better bazaar prices

This commit is contained in:
Linnea Gräf
2025-06-26 21:22:41 +02:00
parent 04fd3b66df
commit e5ff77c47f
7 changed files with 18 additions and 13 deletions

View File

@@ -58,7 +58,7 @@ devauth = "1.2.1"
ktor = "3.1.2" ktor = "3.1.2"
# Update from https://repo.nea.moe/#/releases/moe/nea/neurepoparser # Update from https://repo.nea.moe/#/releases/moe/nea/neurepoparser
neurepoparser = "1.7.0" neurepoparser = "1.8.0"
# Update from https://github.com/HotswapProjects/HotswapAgent/releases # Update from https://github.com/HotswapProjects/HotswapAgent/releases
# TODO: bump to 2.0.1 # TODO: bump to 2.0.1

View File

@@ -35,6 +35,7 @@ import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.ScreenUtil import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.SkyblockId import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.accessors.messages import moe.nea.firmament.util.accessors.messages
import moe.nea.firmament.util.asBazaarStock
import moe.nea.firmament.util.collections.InstanceList import moe.nea.firmament.util.collections.InstanceList
import moe.nea.firmament.util.collections.WeakCache import moe.nea.firmament.util.collections.WeakCache
import moe.nea.firmament.util.mc.SNbtFormatter import moe.nea.firmament.util.mc.SNbtFormatter
@@ -160,7 +161,7 @@ fun firmamentCommand() = literal("firmament") {
thenExecute { thenExecute {
val itemName = SkyblockId(get(item)) val itemName = SkyblockId(get(item))
source.sendFeedback(Text.stringifiedTranslatable("firmament.price", itemName.neuItem)) source.sendFeedback(Text.stringifiedTranslatable("firmament.price", itemName.neuItem))
val bazaarData = HypixelStaticData.bazaarData[itemName] val bazaarData = HypixelStaticData.bazaarData[itemName.asBazaarStock]
if (bazaarData != null) { if (bazaarData != null) {
source.sendFeedback(Text.translatable("firmament.price.bazaar")) source.sendFeedback(Text.translatable("firmament.price.bazaar"))
source.sendFeedback( source.sendFeedback(

View File

@@ -10,6 +10,7 @@ import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.ItemCache.isBroken import moe.nea.firmament.repo.ItemCache.isBroken
import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.MC import moe.nea.firmament.util.MC
import moe.nea.firmament.util.asBazaarStock
import moe.nea.firmament.util.focusedItemStack import moe.nea.firmament.util.focusedItemStack
import moe.nea.firmament.util.skyBlockId import moe.nea.firmament.util.skyBlockId
import moe.nea.firmament.util.skyblock.SBItemUtil.getSearchName import moe.nea.firmament.util.skyblock.SBItemUtil.getSearchName
@@ -28,7 +29,7 @@ object ItemHotkeys {
var item = event.screen.focusedItemStack ?: return var item = event.screen.focusedItemStack ?: return
val skyblockId = item.skyBlockId ?: return val skyblockId = item.skyBlockId ?: return
item = RepoManager.getNEUItem(skyblockId)?.asItemStack()?.takeIf { !it.isBroken } ?: item item = RepoManager.getNEUItem(skyblockId)?.asItemStack()?.takeIf { !it.isBroken } ?: item
if (HypixelStaticData.hasBazaarStock(skyblockId)) { if (HypixelStaticData.hasBazaarStock(skyblockId.asBazaarStock)) {
MC.sendCommand("bz ${item.getSearchName()}") MC.sendCommand("bz ${item.getSearchName()}")
} else if (HypixelStaticData.hasAuctionHouseOffers(skyblockId)) { } else if (HypixelStaticData.hasAuctionHouseOffers(skyblockId)) {
MC.sendCommand("ahs ${item.getSearchName()}") MC.sendCommand("ahs ${item.getSearchName()}")

View File

@@ -9,6 +9,7 @@ import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.gui.config.ManagedConfig import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.repo.HypixelStaticData import moe.nea.firmament.repo.HypixelStaticData
import moe.nea.firmament.util.FirmFormatters.formatCommas import moe.nea.firmament.util.FirmFormatters.formatCommas
import moe.nea.firmament.util.asBazaarStock
import moe.nea.firmament.util.bold import moe.nea.firmament.util.bold
import moe.nea.firmament.util.darkGrey import moe.nea.firmament.util.darkGrey
import moe.nea.firmament.util.gold import moe.nea.firmament.util.gold
@@ -75,7 +76,7 @@ object PriceData : FirmamentFeature {
"firmament.tooltip.multiply.hint", "firmament.tooltip.multiply.hint",
"[${TConfig.stackSizeKey.format()}] to show x${stackSize}" "[${TConfig.stackSizeKey.format()}] to show x${stackSize}"
).darkGrey() ).darkGrey()
val bazaarData = HypixelStaticData.bazaarData[sbId] val bazaarData = HypixelStaticData.bazaarData[sbId?.asBazaarStock]
val lowestBin = HypixelStaticData.lowestBin[sbId] val lowestBin = HypixelStaticData.lowestBin[sbId]
val avgBinValue: Double? = when (TConfig.avgLowestBin) { val avgBinValue: Double? = when (TConfig.avgLowestBin) {
AvgLowestBin.ONEDAYAVGLOWESTBIN -> HypixelStaticData.avg1dlowestBin[sbId] AvgLowestBin.ONEDAYAVGLOWESTBIN -> HypixelStaticData.avg1dlowestBin[sbId]

View File

@@ -27,7 +27,7 @@ object HypixelStaticData {
private set private set
var avg7dlowestBin: Map<SkyblockId, Double> = mapOf() var avg7dlowestBin: Map<SkyblockId, Double> = mapOf()
private set private set
var bazaarData: Map<SkyblockId, BazaarData> = mapOf() var bazaarData: Map<SkyblockId.BazaarStock, BazaarData> = mapOf()
private set private set
var collectionData: Map<String, CollectionSkillData> = mapOf() var collectionData: Map<String, CollectionSkillData> = mapOf()
private set private set
@@ -58,9 +58,10 @@ object HypixelStaticData {
val products: Map<SkyblockId.BazaarStock, BazaarData> = mapOf(), val products: Map<SkyblockId.BazaarStock, BazaarData> = mapOf(),
) )
fun getPriceOfItem(item: SkyblockId): Double? = bazaarData[item]?.quickStatus?.buyPrice ?: lowestBin[item]
fun hasBazaarStock(item: SkyblockId): Boolean { fun getPriceOfItem(item: SkyblockId): Double? = bazaarData[SkyblockId.BazaarStock.fromSkyBlockId(item)]?.quickStatus?.buyPrice ?: lowestBin[item]
fun hasBazaarStock(item: SkyblockId.BazaarStock): Boolean {
return item in bazaarData return item in bazaarData
} }
@@ -105,7 +106,7 @@ object HypixelStaticData {
if (!response.success) { if (!response.success) {
logger.warn("Retrieved unsuccessful bazaar data") logger.warn("Retrieved unsuccessful bazaar data")
} }
bazaarData = response.products.mapKeys { it.key.toRepoId() } bazaarData = response.products
} }
private suspend fun updateCollectionData() { private suspend fun updateCollectionData() {

View File

@@ -9,7 +9,7 @@ enum class BazaarPriceStrategy {
NPC_SELL; NPC_SELL;
fun getSellPrice(skyblockId: SkyblockId): Double { fun getSellPrice(skyblockId: SkyblockId): Double {
val bazaarEntry = HypixelStaticData.bazaarData[skyblockId] ?: return 0.0 val bazaarEntry = HypixelStaticData.bazaarData[skyblockId.asBazaarStock] ?: return 0.0
return when (this) { return when (this) {
BUY_ORDER -> bazaarEntry.quickStatus.sellPrice BUY_ORDER -> bazaarEntry.quickStatus.sellPrice
SELL_ORDER -> bazaarEntry.quickStatus.buyPrice SELL_ORDER -> bazaarEntry.quickStatus.buyPrice

View File

@@ -29,6 +29,7 @@ import net.minecraft.util.Identifier
import moe.nea.firmament.repo.ExpLadders import moe.nea.firmament.repo.ExpLadders
import moe.nea.firmament.repo.ExpensiveItemCacheApi import moe.nea.firmament.repo.ExpensiveItemCacheApi
import moe.nea.firmament.repo.ItemCache.asItemStack import moe.nea.firmament.repo.ItemCache.asItemStack
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.repo.set import moe.nea.firmament.repo.set
import moe.nea.firmament.util.collections.WeakCache import moe.nea.firmament.util.collections.WeakCache
import moe.nea.firmament.util.json.DashlessUUIDSerializer import moe.nea.firmament.util.json.DashlessUUIDSerializer
@@ -69,11 +70,10 @@ value class SkyblockId(val neuItem: String) : Comparable<SkyblockId> {
@JvmInline @JvmInline
@Serializable @Serializable
value class BazaarStock(val bazaarId: String) { value class BazaarStock(val bazaarId: String) {
fun toRepoId(): SkyblockId { companion object {
bazaarEnchantmentRegex.matchEntire(bazaarId)?.let { fun fromSkyBlockId(skyblockId: SkyblockId): BazaarStock {
return SkyblockId("${it.groupValues[1]};${it.groupValues[2]}") return BazaarStock(RepoManager.neuRepo.constants.bazaarStocks.getBazaarStockOrDefault(skyblockId.neuItem))
} }
return SkyblockId(bazaarId.replace(":", "-"))
} }
} }
@@ -92,6 +92,7 @@ value class SkyblockId(val neuItem: String) : Comparable<SkyblockId> {
val NEUItem.skyblockId get() = SkyblockId(skyblockItemId) val NEUItem.skyblockId get() = SkyblockId(skyblockItemId)
val NEUIngredient.skyblockId get() = SkyblockId(itemId) val NEUIngredient.skyblockId get() = SkyblockId(itemId)
val SkyblockId.asBazaarStock get() = SkyblockId.BazaarStock.fromSkyBlockId(this)
@ExpensiveItemCacheApi @ExpensiveItemCacheApi
fun NEUItem.guessRecipeId(): String? { fun NEUItem.guessRecipeId(): String? {