feat: AVG Lowest BIN in Price Data Feature
This commit is contained in:
@@ -2,6 +2,7 @@ package moe.nea.firmament.features.inventory
|
|||||||
|
|
||||||
import org.lwjgl.glfw.GLFW
|
import org.lwjgl.glfw.GLFW
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
|
import net.minecraft.util.StringIdentifiable
|
||||||
import moe.nea.firmament.annotations.Subscribe
|
import moe.nea.firmament.annotations.Subscribe
|
||||||
import moe.nea.firmament.events.ItemTooltipEvent
|
import moe.nea.firmament.events.ItemTooltipEvent
|
||||||
import moe.nea.firmament.features.FirmamentFeature
|
import moe.nea.firmament.features.FirmamentFeature
|
||||||
@@ -23,6 +24,22 @@ object PriceData : FirmamentFeature {
|
|||||||
val tooltipEnabled by toggle("enable-always") { true }
|
val tooltipEnabled by toggle("enable-always") { true }
|
||||||
val enableKeybinding by keyBindingWithDefaultUnbound("enable-keybind")
|
val enableKeybinding by keyBindingWithDefaultUnbound("enable-keybind")
|
||||||
val stackSizeKey by keyBinding("stack-size-keybind") { GLFW.GLFW_KEY_LEFT_SHIFT }
|
val stackSizeKey by keyBinding("stack-size-keybind") { GLFW.GLFW_KEY_LEFT_SHIFT }
|
||||||
|
val avgLowestBin by choice(
|
||||||
|
"avg-lowest-bin-days",
|
||||||
|
) {
|
||||||
|
AvgLowestBin.THREEDAYAVGLOWESTBIN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class AvgLowestBin : StringIdentifiable {
|
||||||
|
OFF,
|
||||||
|
ONEDAYAVGLOWESTBIN,
|
||||||
|
THREEDAYAVGLOWESTBIN,
|
||||||
|
SEVENDAYAVGLOWESTBIN;
|
||||||
|
|
||||||
|
override fun asString(): String {
|
||||||
|
return name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val config get() = TConfig
|
override val config get() = TConfig
|
||||||
@@ -60,6 +77,12 @@ object PriceData : FirmamentFeature {
|
|||||||
).darkGrey()
|
).darkGrey()
|
||||||
val bazaarData = HypixelStaticData.bazaarData[sbId]
|
val bazaarData = HypixelStaticData.bazaarData[sbId]
|
||||||
val lowestBin = HypixelStaticData.lowestBin[sbId]
|
val lowestBin = HypixelStaticData.lowestBin[sbId]
|
||||||
|
val avgBinValue: Double? = when (TConfig.avgLowestBin) {
|
||||||
|
AvgLowestBin.ONEDAYAVGLOWESTBIN -> HypixelStaticData.avg1dlowestBin[sbId]
|
||||||
|
AvgLowestBin.THREEDAYAVGLOWESTBIN -> HypixelStaticData.avg3dlowestBin[sbId]
|
||||||
|
AvgLowestBin.SEVENDAYAVGLOWESTBIN -> HypixelStaticData.avg7dlowestBin[sbId]
|
||||||
|
AvgLowestBin.OFF -> null
|
||||||
|
}
|
||||||
if (bazaarData != null) {
|
if (bazaarData != null) {
|
||||||
it.lines.add(Text.literal(""))
|
it.lines.add(Text.literal(""))
|
||||||
it.lines.add(multiplierText)
|
it.lines.add(multiplierText)
|
||||||
@@ -84,6 +107,14 @@ object PriceData : FirmamentFeature {
|
|||||||
lowestBin * multiplier
|
lowestBin * multiplier
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if (avgBinValue != null) {
|
||||||
|
it.lines.add(
|
||||||
|
formatPrice(
|
||||||
|
tr("firmament.tooltip.ah.avg-lowestbin", "AVG Lowest BIN"),
|
||||||
|
avgBinValue * multiplier
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,17 @@ package moe.nea.firmament.repo
|
|||||||
import io.ktor.client.call.body
|
import io.ktor.client.call.body
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.lwjgl.glfw.GLFW
|
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.awaitAll
|
import kotlinx.coroutines.awaitAll
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withTimeoutOrNull
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.time.Duration.Companion.minutes
|
import kotlin.time.Duration.Companion.minutes
|
||||||
import moe.nea.firmament.Firmament
|
import moe.nea.firmament.Firmament
|
||||||
import moe.nea.firmament.apis.CollectionResponse
|
import moe.nea.firmament.apis.CollectionResponse
|
||||||
import moe.nea.firmament.apis.CollectionSkillData
|
import moe.nea.firmament.apis.CollectionSkillData
|
||||||
import moe.nea.firmament.keybindings.IKeyBinding
|
|
||||||
import moe.nea.firmament.util.SkyblockId
|
import moe.nea.firmament.util.SkyblockId
|
||||||
import moe.nea.firmament.util.async.waitForInput
|
|
||||||
|
|
||||||
object HypixelStaticData {
|
object HypixelStaticData {
|
||||||
private val logger = LogManager.getLogger("Firmament.HypixelStaticData")
|
private val logger = LogManager.getLogger("Firmament.HypixelStaticData")
|
||||||
@@ -25,6 +21,12 @@ object HypixelStaticData {
|
|||||||
private val hypixelApiBaseUrl = "https://api.hypixel.net"
|
private val hypixelApiBaseUrl = "https://api.hypixel.net"
|
||||||
var lowestBin: Map<SkyblockId, Double> = mapOf()
|
var lowestBin: Map<SkyblockId, Double> = mapOf()
|
||||||
private set
|
private set
|
||||||
|
var avg1dlowestBin: Map<SkyblockId, Double> = mapOf()
|
||||||
|
private set
|
||||||
|
var avg3dlowestBin: Map<SkyblockId, Double> = mapOf()
|
||||||
|
private set
|
||||||
|
var avg7dlowestBin: Map<SkyblockId, Double> = mapOf()
|
||||||
|
private set
|
||||||
var bazaarData: Map<SkyblockId, BazaarData> = mapOf()
|
var bazaarData: Map<SkyblockId, BazaarData> = mapOf()
|
||||||
private set
|
private set
|
||||||
var collectionData: Map<String, CollectionSkillData> = mapOf()
|
var collectionData: Map<String, CollectionSkillData> = mapOf()
|
||||||
@@ -90,6 +92,12 @@ object HypixelStaticData {
|
|||||||
private suspend fun fetchPricesFromMoulberry() {
|
private suspend fun fetchPricesFromMoulberry() {
|
||||||
lowestBin = Firmament.httpClient.get("$moulberryBaseUrl/lowestbin.json")
|
lowestBin = Firmament.httpClient.get("$moulberryBaseUrl/lowestbin.json")
|
||||||
.body<Map<SkyblockId, Double>>()
|
.body<Map<SkyblockId, Double>>()
|
||||||
|
avg1dlowestBin = Firmament.httpClient.get("$moulberryBaseUrl/auction_averages_lbin/1day.json")
|
||||||
|
.body<Map<SkyblockId, Double>>()
|
||||||
|
avg3dlowestBin = Firmament.httpClient.get("$moulberryBaseUrl/auction_averages_lbin/3day.json")
|
||||||
|
.body<Map<SkyblockId, Double>>()
|
||||||
|
avg7dlowestBin = Firmament.httpClient.get("$moulberryBaseUrl/auction_averages_lbin/7day.json")
|
||||||
|
.body<Map<SkyblockId, Double>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun fetchBazaarPrices() {
|
private suspend fun fetchBazaarPrices() {
|
||||||
|
|||||||
@@ -203,6 +203,12 @@
|
|||||||
"firmament.config.power-user.show-item-id": "Show SkyBlock Ids",
|
"firmament.config.power-user.show-item-id": "Show SkyBlock Ids",
|
||||||
"firmament.config.power-user.show-item-id.description": "Show the SkyBlock id of items underneath them.",
|
"firmament.config.power-user.show-item-id.description": "Show the SkyBlock id of items underneath them.",
|
||||||
"firmament.config.price-data": "Price data",
|
"firmament.config.price-data": "Price data",
|
||||||
|
"firmament.config.price-data.avg-lowest-bin-days": "AVG Lowest Bin Days",
|
||||||
|
"firmament.config.price-data.avg-lowest-bin-days.description": "Select if and for how long the AVG Lowest BIN should show.",
|
||||||
|
"firmament.config.price-data.avg-lowest-bin-days.choice.off": "Off",
|
||||||
|
"firmament.config.price-data.avg-lowest-bin-days.choice.onedayavglowestbin": "1 Day",
|
||||||
|
"firmament.config.price-data.avg-lowest-bin-days.choice.threedayavglowestbin": "3 Days",
|
||||||
|
"firmament.config.price-data.avg-lowest-bin-days.choice.sevendayavglowestbin": "7 Days",
|
||||||
"firmament.config.price-data.enable-always": "Enable Item Price",
|
"firmament.config.price-data.enable-always": "Enable Item Price",
|
||||||
"firmament.config.price-data.enable-always.description": "Show item auction/bazaar prices on SkyBlock items",
|
"firmament.config.price-data.enable-always.description": "Show item auction/bazaar prices on SkyBlock items",
|
||||||
"firmament.config.price-data.enable-keybind": "Enable only with Keybinding",
|
"firmament.config.price-data.enable-keybind": "Enable only with Keybinding",
|
||||||
|
|||||||
Reference in New Issue
Block a user