aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/repo
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-06-11 02:43:14 +0200
committernea <nea@nea.moe>2023-06-11 02:43:14 +0200
commita36c8f1c0eae969dcee8cf690f12d9121350212d (patch)
treeea93f19bf5f77f8b5e42a7b56162d9b6492b7fed /src/main/kotlin/moe/nea/firmament/repo
parent040f7c7275568d783bfa5e4ed20412f72d126549 (diff)
downloadfirmament-a36c8f1c0eae969dcee8cf690f12d9121350212d.tar.gz
firmament-a36c8f1c0eae969dcee8cf690f12d9121350212d.tar.bz2
firmament-a36c8f1c0eae969dcee8cf690f12d9121350212d.zip
Add collection info to skill page
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")
+ }
+
}