summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-02 20:43:28 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-02 20:43:28 +0100
commit9484d930bd52ead1af076fc251aed691226ceee5 (patch)
treec95e5ce19b7f21dd725877de260cec4906d11e6b /src/main/java/at/hannibal2/skyhanni/features/misc
parent7b329087dc47842e2a8337e650e6c037230da7ba (diff)
downloadskyhanni-9484d930bd52ead1af076fc251aed691226ceee5.tar.gz
skyhanni-9484d930bd52ead1af076fc251aed691226ceee5.tar.bz2
skyhanni-9484d930bd52ead1af076fc251aed691226ceee5.zip
Prepare for bingo stuff.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
index f2b188787..088836401 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi
import at.hannibal2.skyhanni.features.bazaar.BazaarData
+import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
@@ -62,9 +63,9 @@ class CollectionCounter {
val apiName = data.apiName
if (!apiCollectionData.contains(apiName)) {
if (apiCollectionData.isEmpty()) {
- LorenzUtils.chat("§c[SkyHanni] Collection data not loaded! (API down?)")
+ LorenzUtils.chat("§c[SkyHanni] No Collection Data! API down?")
} else {
- LorenzUtils.chat("§c[SkyHanni] Item $name is not in collection data!")
+ LorenzUtils.chat("§c[SkyHanni] Item $name is not in the collection data!")
}
return
}
@@ -104,18 +105,8 @@ class CollectionCounter {
display = "$itemName collection: §e$format $gainText"
}
- private fun countCurrentlyInInventory(): Int {
- var currentlyInInventory = 0
- val player = Minecraft.getMinecraft().thePlayer
- for (stack in player.inventory.mainInventory) {
- if (stack == null) continue
- val internalName = stack.getInternalName()
- if (internalName == itemApiName) {
- currentlyInInventory += stack.stackSize
- }
- }
- return currentlyInInventory
- }
+ private fun countCurrentlyInInventory() =
+ InventoryUtils.countItemsInLowerInventory { it.getInternalName() == itemApiName }
}
@SubscribeEvent
@@ -168,7 +159,9 @@ class CollectionCounter {
@SubscribeEvent
fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
val profileData = event.profileData
- val collection = profileData["collection"].asJsonObject
+
+ //new profiles don't have any collections
+ val collection = profileData["collection"]?.asJsonObject ?: return
apiCollectionData.clear()
for (entry in collection.entrySet()) {