diff options
author | jani270 <69345714+jani270@users.noreply.github.com> | 2023-12-26 10:26:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-26 10:26:23 +0100 |
commit | 1d6937db0cfbf5db5a22b298615550dd41cf7ae6 (patch) | |
tree | f3056f7e3afcd663c0936843f9da3434bb99767e /src/main/kotlin | |
parent | ac96321d82fb8ee9ebc91ce9501ddcd7b649f47d (diff) | |
download | NotEnoughUpdates-1d6937db0cfbf5db5a22b298615550dd41cf7ae6.tar.gz NotEnoughUpdates-1d6937db0cfbf5db5a22b298615550dd41cf7ae6.tar.bz2 NotEnoughUpdates-1d6937db0cfbf5db5a22b298615550dd41cf7ae6.zip |
Migrating pv to v2 endpoint (#939)
Co-authored-by: efefury <69400149+efefury@users.noreply.github.com>
Co-authored-by: Lulonaut <lulonaut@lulonaut.tech>
Diffstat (limited to 'src/main/kotlin')
3 files changed, 8 insertions, 9 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/SacksPage.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/SacksPage.kt index ebd53c4d..8e5a2973 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/SacksPage.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/profileviewer/SacksPage.kt @@ -369,8 +369,7 @@ class SacksPage(pvInstance: GuiProfileViewer) : GuiProfileViewerPage(pvInstance) val sackTypes = sacksJson.getAsJsonObject("sacks") val selectedProfile = selectedProfile?.profileJson ?: return - if (!selectedProfile.has("sacks_counts") || !selectedProfile.get("sacks_counts").isJsonObject) return - val sacksInfo = selectedProfile.get("sacks_counts").asJsonObject + val sacksInfo = Utils.getElementOrDefault(selectedProfile, "inventory.sacks_counts", JsonObject()).asJsonObject var totalValue = 0.0 var totalItems = 0 diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/UrsaClient.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/UrsaClient.kt index 2320163d..312c5d9b 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/UrsaClient.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/UrsaClient.kt @@ -181,21 +181,21 @@ class UrsaClient(val apiUtil: ApiUtil) { companion object { @JvmStatic - fun profiles(uuid: UUID) = KnownRequest("v1/hypixel/profiles/${uuid}", JsonObject::class.java) + fun profiles(uuid: UUID) = KnownRequest("v1/hypixel/v2/profiles/${uuid}", JsonObject::class.java) @JvmStatic - fun player(uuid: UUID) = KnownRequest("v1/hypixel/player/${uuid}", JsonObject::class.java) + fun player(uuid: UUID) = KnownRequest("v1/hypixel/v2/player/${uuid}", JsonObject::class.java) @JvmStatic - fun guild(uuid: UUID) = KnownRequest("v1/hypixel/guild/${uuid}", JsonObject::class.java) + fun guild(uuid: UUID) = KnownRequest("v1/hypixel/v2/guild/${uuid}", JsonObject::class.java) @JvmStatic - fun bingo(uuid: UUID) = KnownRequest("v1/hypixel/bingo/${uuid}", JsonObject::class.java) + fun bingo(uuid: UUID) = KnownRequest("v1/hypixel/v2/bingo/${uuid}", JsonObject::class.java) @JvmStatic - fun museumForProfile(profileUuid: String) = KnownRequest("v1/hypixel/museum/${profileUuid}", JsonObject::class.java) + fun museumForProfile(profileUuid: String) = KnownRequest("v1/hypixel/v2/museum/${profileUuid}", JsonObject::class.java) @JvmStatic - fun status(uuid: UUID) = KnownRequest("v1/hypixel/status/${uuid}", JsonObject::class.java) + fun status(uuid: UUID) = KnownRequest("v1/hypixel/v2/status/${uuid}", JsonObject::class.java) } } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/hypixelapi/Collection.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/hypixelapi/Collection.kt index e5c7263c..9a6a8c9f 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/hypixelapi/Collection.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/hypixelapi/Collection.kt @@ -118,7 +118,7 @@ data class ProfileCollectionInfo( } val generators = members.entrySet().mapNotNull { (uuid, data) -> if (data !is JsonObject) return null - data["crafted_generators"] as? JsonArray + data.getAsJsonObject("player_data")?.get("crafted_generators") as? JsonArray }.flatMap { it.toList() } return ProfileCollectionInfo( collectionData.allCollections.mapValues { (name, collection) -> |