WIP: Reforge recipes

This commit is contained in:
Linnea Gräf
2024-12-24 03:58:43 +01:00
parent fbab19b40f
commit e16c60169b
17 changed files with 858 additions and 93 deletions

View File

@@ -125,10 +125,26 @@ val ItemStack.skyblockUUID: UUID?
private val petDataCache = WeakCache.memoize<ItemStack, Optional<HypixelPetInfo>>("PetInfo") {
val jsonString = it.extraAttributes.getString("petInfo")
if (jsonString.isNullOrBlank()) return@memoize Optional.empty()
ErrorUtil.catch<HypixelPetInfo?>("Could not decode hypixel pet info") { jsonparser.decodeFromString<HypixelPetInfo>(jsonString) }
ErrorUtil.catch<HypixelPetInfo?>("Could not decode hypixel pet info") {
jsonparser.decodeFromString<HypixelPetInfo>(jsonString)
}
.or { null }.intoOptional()
}
fun ItemStack.getUpgradeStars(): Int {
return extraAttributes.getInt("upgrade_level").takeIf { it > 0 }
?: extraAttributes.getInt("dungeon_item_level").takeIf { it > 0 }
?: 0
}
@Serializable
@JvmInline
value class ReforgeId(val id: String)
fun ItemStack.getReforgeId(): ReforgeId? {
return extraAttributes.getString("modifier").takeIf { it.isNotBlank() }?.let(::ReforgeId)
}
val ItemStack.petData: HypixelPetInfo?
get() = petDataCache(this).getOrNull()