aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/api
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <nea@nea.moe>2023-03-19 17:58:54 +0100
committerGitHub <noreply@github.com>2023-03-19 17:58:54 +0100
commit86d6cc6bf29172fb13ed6aab2ca0676631336da9 (patch)
treed5e0fc0aa6a556c44f497d818f36e674a0f2e317 /src/main/java/at/hannibal2/skyhanni/api
parent4d3e68e8777ac174b938ad63c3367a20e99e06ac (diff)
parent6913b635b9d20cc6736aef64bad9f5d517a2f644 (diff)
downloadSkyHanni-yaw_snapping.tar.gz
SkyHanni-yaw_snapping.tar.bz2
SkyHanni-yaw_snapping.zip
Merge branch 'beta' into yaw_snappingyaw_snapping
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
index e79e60dfb..f86819895 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
@@ -1,11 +1,13 @@
package at.hannibal2.skyhanni.api
+import at.hannibal2.skyhanni.events.CollectionUpdateEvent
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
@@ -14,10 +16,19 @@ class CollectionAPI {
private val counterPattern = Pattern.compile("(?:.*) §e(.*)§6\\/(?:.*)")
private val singleCounterPattern = Pattern.compile("§7Total Collected: §e(.*)")
+ private val hypixelApiHasWrongItems = listOf(
+ "WOOL",
+ "CORRUPTED_FRAGMENT",
+ "EGG",
+ "POISONOUS_POTATO",
+ )
+
@SubscribeEvent
fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
val profileData = event.profileData
- for ((rawName, rawCounter) in profileData["collection"].asJsonObject.entrySet()) {
+ val jsonElement = profileData["collection"]?: return
+ val asJsonObject = jsonElement.asJsonObject ?: return
+ for ((rawName, rawCounter) in asJsonObject.entrySet()) {
val counter = rawCounter.asLong
var itemName = BazaarApi.getBazaarDataForInternalName(rawName)?.itemName
if (rawName == "MUSHROOM_COLLECTION") {
@@ -29,16 +40,19 @@ class CollectionAPI {
if (rawName == "GEMSTONE_COLLECTION") {
itemName = "Gemstone"
}
+
// Hypixel moment
- if (rawName == "WOOL" || rawName == "CORRUPTED_FRAGMENT") {
- continue
- }
+ if (hypixelApiHasWrongItems.contains(rawName)) continue
+
if (itemName == null) {
- println("collection name is null for '$rawName'")
+ LorenzUtils.debug("collection name is null for '$rawName'")
+ println()
continue
}
collectionValue[itemName] = counter
}
+
+ CollectionUpdateEvent().postAndCatch()
}
@SubscribeEvent
@@ -59,6 +73,7 @@ class CollectionAPI {
collectionValue[name] = counter
}
}
+ CollectionUpdateEvent().postAndCatch()
}
if (inventoryName.endsWith(" Collections")) {
@@ -83,6 +98,7 @@ class CollectionAPI {
}
}
}
+ CollectionUpdateEvent().postAndCatch()
}
}