aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/nextstep/CollectionStep.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt11
5 files changed, 24 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
index 8fd1b4cb5..c5f6c6e0a 100644
--- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
@@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.events.CollectionUpdateEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_new
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -91,19 +90,14 @@ class CollectionAPI {
fun isCollectionTier0(lore: List<String>) = lore.map { collectionTier0Pattern.matcher(it) }.any { it.matches() }
- fun getCollectionCounter(itemName: String) = getCollectionCounter(NEUItems.getInternalName_new(itemName))
-
fun getCollectionCounter(internalName: NEUInternalName) = collectionValue[internalName]
// TODO add support for replenish (higher collection than actual items in inv)
- fun addFromInventory(internalNameRaw: String, amount: Int) {
- val stack = NEUItems.getItemStackOrNull(internalNameRaw)
- if (stack == null) {
- LorenzUtils.debug("CollectionAPI.addFromInventory: internalName is null for '$internalNameRaw'")
+ fun addFromInventory(internalName: NEUInternalName, amount: Int) {
+ if (internalName.getItemStackOrNull() == null) {
+ LorenzUtils.debug("CollectionAPI.addFromInventory: item is null for '$internalName'")
return
}
- val internalName = stack.getInternalName_new()
-
collectionValue.addOrPut(internalName, amount.toLong())
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
index f366f0aed..5bae57ac5 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
@@ -5,9 +5,10 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.OwnInventorItemUpdateEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull_new
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import net.minecraft.item.ItemStack
import net.minecraft.network.play.server.S2FPacketSetSlot
@@ -74,21 +75,21 @@ class OwnInventoryData {
val diffWorld = System.currentTimeMillis() - LorenzUtils.lastWorldSwitch
if (diffWorld < 3_000) return
- val internalName = item.getInternalName()
- if (internalName.startsWith("MAP-")) return
+ val internalName = item.getInternalNameOrNull_new()
- val (_, amount) = NEUItems.getMultiplier(internalName)
- if (amount > 1) return
-
- if (internalName == "") {
+ if (internalName == null) {
LorenzUtils.debug("OwnInventoryData add is empty for: '$internalName'")
return
}
+ if (internalName.asString().startsWith("MAP-")) return
+
+ val (_, amount) = NEUItems.getMultiplier(internalName)
+ if (amount > 1) return
addMultiplier(internalName, add)
}
- private fun addMultiplier(internalName: String, amount: Int) {
+ private fun addMultiplier(internalName: NEUInternalName, amount: Int) {
CollectionAPI.addFromInventory(internalName, amount)
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
index e740d0af2..b71b4f4a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt
@@ -177,7 +177,7 @@ class BingoNextStepHelper {
}
}
if (step is CollectionStep) {
- val counter = CollectionAPI.getCollectionCounter(step.collectionName) ?: 0
+ val counter = CollectionAPI.getCollectionCounter(step.internalName) ?: 0
if (step.amountHaving != counter) {
step.amountHaving = counter
if (counter >= step.amountNeeded) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/nextstep/CollectionStep.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/nextstep/CollectionStep.kt
index 065f92f9b..892bedcd1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/nextstep/CollectionStep.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/nextstep/CollectionStep.kt
@@ -1,6 +1,9 @@
package at.hannibal2.skyhanni.features.bingo.nextstep
+import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.NumberUtil
-class CollectionStep(val collectionName: String, amountNeeded: Int) :
- ProgressionStep(NumberUtil.format(amountNeeded) + " $collectionName Collection", amountNeeded.toLong()) \ No newline at end of file
+class CollectionStep(collectionName: String, amountNeeded: Int) :
+ ProgressionStep(NumberUtil.format(amountNeeded) + " $collectionName Collection", amountNeeded.toLong()) {
+ val internalName = NEUItems.getInternalName_new(collectionName)
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt
index 9be2186ad..05aefc1f4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt
@@ -4,12 +4,13 @@ import at.hannibal2.skyhanni.api.CollectionAPI
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.MinionOpenEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_new
+import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUItems
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class MinionCollectLogic {
- private var oldMap = mapOf<String, Int>()
+ private var oldMap = mapOf<NEUInternalName, Int>()
@SubscribeEvent
fun onMinionOpen(event: MinionOpenEvent) {
@@ -17,10 +18,10 @@ class MinionCollectLogic {
oldMap = count()
}
- private fun count(): MutableMap<String, Int> {
- val map = mutableMapOf<String, Int>()
+ private fun count(): MutableMap<NEUInternalName, Int> {
+ val map = mutableMapOf<NEUInternalName, Int>()
for (stack in InventoryUtils.getItemsInOwnInventory()) {
- val internalName = stack.getInternalName()
+ val internalName = stack.getInternalName_new()
val (newId, amount) = NEUItems.getMultiplier(internalName)
val old = map[newId] ?: 0
map[newId] = old + amount * stack.stackSize