diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-24 03:58:43 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-24 23:35:29 +0100 |
commit | e16c60169bf192b79991176b5f9cee66b5b16e7d (patch) | |
tree | 8574fc28d83abe646c23dff336185a9d2ae7f637 /src/main/kotlin/util/SkyblockId.kt | |
parent | fbab19b40f72574b7930ddd2981998b2d2845471 (diff) | |
download | Firmament-e16c60169bf192b79991176b5f9cee66b5b16e7d.tar.gz Firmament-e16c60169bf192b79991176b5f9cee66b5b16e7d.tar.bz2 Firmament-e16c60169bf192b79991176b5f9cee66b5b16e7d.zip |
WIP: Reforge recipes
Diffstat (limited to 'src/main/kotlin/util/SkyblockId.kt')
-rw-r--r-- | src/main/kotlin/util/SkyblockId.kt | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/kotlin/util/SkyblockId.kt b/src/main/kotlin/util/SkyblockId.kt index 1c1aa77..497a2d2 100644 --- a/src/main/kotlin/util/SkyblockId.kt +++ b/src/main/kotlin/util/SkyblockId.kt @@ -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() |