aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-05-18 12:56:20 +0200
committerGitHub <noreply@github.com>2024-05-18 12:56:20 +0200
commitf0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed (patch)
treeacab9c69aa98f5cb2923f8dc62011275fa8d9096 /src/main/java/at/hannibal2/skyhanni/data
parentdea8da66d4aa933b63df691d9db9d4eafc0a5e0e (diff)
downloadskyhanni-f0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed.tar.gz
skyhanni-f0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed.tar.bz2
skyhanni-f0aa9df4c216a0c9dedbd6bf186d17e3aa1717ed.zip
Fix: Quiver Warning (#1832)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
index b13538c9b..c40b291e6 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.data.jsonobjects.repo.ArrowTypeJson
-import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
@@ -9,7 +8,6 @@ import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
import at.hannibal2.skyhanni.events.QuiverUpdateEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
-import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemCategory
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -45,9 +43,14 @@ object QuiverAPI {
storage?.arrows?.arrowAmount = value
}
var currentAmount: Int
- get() = arrowAmount[currentArrow?.internalName]?.toInt() ?: 0
+ get() = currentArrow?.amount ?: 0
set(value) {
- arrowAmount[currentArrow?.internalName ?: return] = value
+ currentArrow?.amount = value
+ }
+ var ArrowType.amount: Int
+ get() = arrowAmount[this.internalName] ?: 0
+ set(value) {
+ arrowAmount[this.internalName] = value
}
private var arrows: List<ArrowType> = listOf()
@@ -120,7 +123,7 @@ object QuiverAPI {
"Unknown arrow type: $type",
"message" to message,
)
- arrowAmount[ranOutType.internalName] = 0
+ ranOutType.amount = 0
postUpdateEvent(ranOutType)
}
@@ -134,19 +137,17 @@ object QuiverAPI {
"message" to message,
)
- arrowAmount.addOrPut(filledUpType.internalName, amount)
+ filledUpType.amount += amount
if (filledUpType == currentArrow) {
postUpdateEvent()
}
return
-
}
fillUpPattern.matchMatcher(message) {
val flintAmount = group("flintAmount").formatInt()
- FLINT_ARROW_TYPE?.let { arrowAmount.addOrPut(it.internalName, flintAmount) }
-
+ FLINT_ARROW_TYPE?.let { it.amount += flintAmount }
if (currentArrow == FLINT_ARROW_TYPE) {
postUpdateEvent()
}
@@ -156,7 +157,6 @@ object QuiverAPI {
addedToQuiverPattern.matchMatcher(message) {
val type = group("type")
val amount = group("amount").formatInt()
-
val filledUpType = getArrowByNameOrNull(type)
?: return ErrorManager.logErrorWithData(
UnknownArrowType("Unknown arrow type: $type"),
@@ -164,7 +164,7 @@ object QuiverAPI {
"message" to message,
)
- arrowAmount.addOrPut(filledUpType.internalName, amount)
+ filledUpType.amount += amount
if (filledUpType == currentArrow) {
postUpdateEvent()
}
@@ -202,8 +202,7 @@ object QuiverAPI {
if (stack.getItemCategoryOrNull() != ItemCategory.ARROW) continue
val arrow = stack.getInternalNameOrNull() ?: continue
val arrowType = getArrowByNameOrNull(arrow) ?: continue
-
- arrowAmount.addOrPut(arrowType.internalName, stack.stackSize)
+ arrowType.amount += stack.stackSize
}
}
@@ -270,7 +269,7 @@ object QuiverAPI {
}
private fun postUpdateEvent(arrowType: ArrowType? = currentArrow) {
- QuiverUpdateEvent(arrowType, currentAmount, wearingSkeletonMasterChestplate).postAndCatch()
+ QuiverUpdateEvent(arrowType, currentAmount).postAndCatch()
}
@SubscribeEvent
@@ -285,9 +284,6 @@ object QuiverAPI {
// Load arrows from repo
@SubscribeEvent
fun onRepoReload(event: RepositoryReloadEvent) {
- val itemData = event.getConstant<ItemsJson>("Items")
- infinityQuiverLevelMultiplier = itemData.enchant_multiplier["infinite_quiver"] ?: 0.03f
-
val arrowData = event.getConstant<ArrowTypeJson>("ArrowTypes")
arrows = arrowData.arrows.map { ArrowType(it.value.arrow, it.key.asInternalName()) }