aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/repo
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/repo')
-rw-r--r--src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt (renamed from src/main/kotlin/moe/nea/firmament/repo/ItemCostData.kt)23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/repo/ItemCostData.kt b/src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt
index a1084b9..f2a2668 100644
--- a/src/main/kotlin/moe/nea/firmament/repo/ItemCostData.kt
+++ b/src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt
@@ -12,18 +12,23 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlin.time.Duration.Companion.minutes
import moe.nea.firmament.Firmament
+import moe.nea.firmament.apis.CollectionResponse
+import moe.nea.firmament.apis.CollectionSkillData
+import moe.nea.firmament.apis.Skill
import moe.nea.firmament.keybindings.IKeyBinding
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.async.waitForInput
-object ItemCostData {
- private val logger = LogManager.getLogger("Firmament.ItemCostData")
+object HypixelStaticData {
+ private val logger = LogManager.getLogger("Firmament.HypixelStaticData")
private val moulberryBaseUrl = "https://moulberry.codes"
private val hypixelApiBaseUrl = "https://api.hypixel.net"
var lowestBin: Map<SkyblockId, Double> = mapOf()
private set
var bazaarData: Map<SkyblockId, BazaarData> = mapOf()
private set
+ var collectionData: Map<Skill, CollectionSkillData> = mapOf()
+ private set
@Serializable
data class BazaarData(
@@ -53,7 +58,9 @@ object ItemCostData {
fun getPriceOfItem(item: SkyblockId): Double? = bazaarData[item]?.quickStatus?.buyPrice ?: lowestBin[item]
- fun spawnPriceLoop() {
+
+ fun spawnDataCollectionLoop() {
+ Firmament.coroutineScope.launch { updateCollectionData() }
Firmament.coroutineScope.launch {
while (true) {
logger.info("Updating NEU prices")
@@ -83,4 +90,14 @@ object ItemCostData {
bazaarData = response.products.mapKeys { it.key.toRepoId() }
}
+ private suspend fun updateCollectionData() {
+ val response =
+ Firmament.httpClient.get("$hypixelApiBaseUrl/resources/skyblock/collections").body<CollectionResponse>()
+ if (!response.success) {
+ logger.warn("Retrieved unsuccessful collection data")
+ }
+ collectionData = response.collections
+ logger.info("Downloaded ${collectionData.values.sumOf { it.items.values.size }} collections")
+ }
+
}