aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
index d8c5f35de..733e8709f 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
@@ -8,6 +8,7 @@ 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.NEUItems
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern
@@ -27,7 +28,7 @@ class CollectionAPI {
@SubscribeEvent
fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) {
val profileData = event.profileData
- val jsonElement = profileData["collection"]?: return
+ val jsonElement = profileData["collection"] ?: return
val asJsonObject = jsonElement.asJsonObject ?: return
for ((rawName, rawCounter) in asJsonObject.entrySet()) {
val counter = rawCounter.asLong
@@ -116,5 +117,15 @@ class CollectionAPI {
}
return null
}
+
+ // TODO add support for replenish (higher collection than actual items in inv)
+ fun addFromInventory(internalName: String, amount: Int) {
+ val name = NEUItems.getItemStack(internalName).name?.removeColor() ?: return
+
+ val oldValue = collectionValue[name] ?: return
+
+ val newValue = oldValue + amount
+ collectionValue[name] = newValue
+ }
}
} \ No newline at end of file