aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-30 14:40:53 +0200
committernea <nea@nea.moe>2023-07-30 14:40:53 +0200
commit2f700453a4f688898c2c0040b3e0a628e89fa335 (patch)
tree8758fc631a6b898ecd9e0d99331244157d6f4fa4
parentd4b254ea11798a8ba4b891d31c433496b7c53bb3 (diff)
downloadFirmament-2f700453a4f688898c2c0040b3e0a628e89fa335.tar.gz
Firmament-2f700453a4f688898c2c0040b3e0a628e89fa335.tar.bz2
Firmament-2f700453a4f688898c2c0040b3e0a628e89fa335.zip
Fix skill data breaking collections
-rw-r--r--src/main/kotlin/moe/nea/firmament/apis/Profiles.kt2
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt16
-rw-r--r--src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt7
3 files changed, 16 insertions, 9 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/apis/Profiles.kt b/src/main/kotlin/moe/nea/firmament/apis/Profiles.kt
index 553fd9f..0f014a5 100644
--- a/src/main/kotlin/moe/nea/firmament/apis/Profiles.kt
+++ b/src/main/kotlin/moe/nea/firmament/apis/Profiles.kt
@@ -27,7 +27,7 @@ data class CollectionSkillData(
@Serializable
data class CollectionResponse(
val success: Boolean,
- val collections: Map<Skill, CollectionSkillData>
+ val collections: Map<String, CollectionSkillData>
)
@Serializable
diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
index 8dc606c..239c743 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/SkillPage.kt
@@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.text.Style
import net.minecraft.text.Text
+import net.minecraft.util.DyeColor
import net.minecraft.util.Formatting
import moe.nea.firmament.apis.CollectionInfo
import moe.nea.firmament.apis.CollectionType
@@ -56,7 +57,7 @@ object SkillPage : ProfilePage {
}
}
- private fun collectionItem(type: CollectionType, info: CollectionInfo, skill: Skill, member: Member): WWidget {
+ private fun collectionItem(type: CollectionType, info: CollectionInfo, color: DyeColor, member: Member): WWidget {
val collectionCount = member.collection[type] ?: 0
val unlockedTiers = info.tiers.count { it.amountRequired <= collectionCount }
return WTitledItem(
@@ -65,7 +66,7 @@ object SkillPage : ProfilePage {
it.setCustomName(
Text.literal(info.name).fillStyle(
Style.EMPTY.withItalic(false).withBold(true)
- .withColor(skill.color.toTextColor())
+ .withColor(color.toTextColor())
)
)
it.modifyLore { old ->
@@ -91,6 +92,9 @@ object SkillPage : ProfilePage {
val data = HypixelStaticData.collectionData
val panels = mutableListOf<WPanel>()
for ((skill, collections) in data.entries) {
+ val skillT = Skill.values().find { it.name == skill }
+ val color = skillT?.color ?: DyeColor.BLACK
+ val icon = skillT?.icon?.let { RepoManager.getNEUItem(it).asItemStack() } ?: ItemStack(Items.ITEM_FRAME)
val panel = WBox(Axis.HORIZONTAL).also {
it.horizontalAlignment = HorizontalAlignment.CENTER
it.add(WFixedPanel(WGridPanel().also {
@@ -99,7 +103,7 @@ object SkillPage : ProfilePage {
var x = 0
var y = 0
for (item in collections.items) {
- it.add(collectionItem(item.key, item.value, skill, profileViewer.member), x, y, 1, 1)
+ it.add(collectionItem(item.key, item.value, color, profileViewer.member), x, y, 1, 1)
x++
if (x == 5) {
x = 0
@@ -111,9 +115,9 @@ object SkillPage : ProfilePage {
panels.add(panel)
it.add(panel) {
it.tooltip(
- Text.translatable("firmament.pv.skills.${skill.name.lowercase()}")
- .styled { it.withColor(skill.color.toTextColor()) })
- it.icon(ItemIcon(RepoManager.getNEUItem(skill.icon).asItemStack()))
+ Text.translatable("firmament.pv.skills.${skill.lowercase()}")
+ .styled { it.withColor(color.toTextColor()) })
+ it.icon(ItemIcon(icon))
}
}
it.layout()
diff --git a/src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt b/src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt
index f2a2668..a5860ae 100644
--- a/src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt
+++ b/src/main/kotlin/moe/nea/firmament/repo/HypixelStaticData.kt
@@ -27,7 +27,7 @@ object HypixelStaticData {
private set
var bazaarData: Map<SkyblockId, BazaarData> = mapOf()
private set
- var collectionData: Map<Skill, CollectionSkillData> = mapOf()
+ var collectionData: Map<String, CollectionSkillData> = mapOf()
private set
@Serializable
@@ -60,7 +60,10 @@ object HypixelStaticData {
fun spawnDataCollectionLoop() {
- Firmament.coroutineScope.launch { updateCollectionData() }
+ Firmament.coroutineScope.launch {
+ logger.info("Updating collection data")
+ updateCollectionData()
+ }
Firmament.coroutineScope.launch {
while (true) {
logger.info("Updating NEU prices")