aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-12 18:04:56 +0100
committerGitHub <noreply@github.com>2024-03-12 18:04:56 +0100
commitb808a6aea1ba28ffd10712e7586b6f0d6cc1804a (patch)
tree1c4b9f8eacd97718b4042393a39c0ccbccf8dfa9 /src/main/java
parent9f1ba8207e8ae14da50058eeaaf0eb750b530dfa (diff)
downloadskyhanni-b808a6aea1ba28ffd10712e7586b6f0d6cc1804a.tar.gz
skyhanni-b808a6aea1ba28ffd10712e7586b6f0d6cc1804a.tar.bz2
skyhanni-b808a6aea1ba28ffd10712e7586b6f0d6cc1804a.zip
Internal Change: Code cleanup ContainerChest getAllItems (#1047)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt22
14 files changed, 60 insertions, 76 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt
index eddd232bd..9e9992ab1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt
@@ -3,6 +3,8 @@ package at.hannibal2.skyhanni.features.anvil
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+import at.hannibal2.skyhanni.utils.InventoryUtils.getLowerItems
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -26,14 +28,9 @@ class AnvilCombineHelper {
val matchLore = mutableListOf<String>()
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
-
- if (slot.slotNumber != slot.slotIndex) continue
- if (slot.stack == null) continue
-
+ for ((slot, stack) in chest.getUpperItems()) {
if (slot.slotNumber == 29) {
- val lore = slot.stack.getLore()
+ val lore = stack.getLore()
matchLore.addAll(lore)
break
}
@@ -41,16 +38,10 @@ class AnvilCombineHelper {
if (matchLore.isEmpty()) return
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
-
- if (slot.slotNumber == slot.slotIndex) continue
- if (slot.stack == null) continue
-
-
- if (matchLore == slot.stack.getLore()) {
+ for ((slot, stack) in chest.getLowerItems()) {
+ if (matchLore == stack.getLore()) {
slot highlight LorenzColor.GREEN
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
index 430f139c2..f222040df 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.features.bingo.BingoAPI.getData
import at.hannibal2.skyhanni.features.bingo.card.goals.GoalType
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
@@ -83,9 +84,7 @@ class BingoCardTips {
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
-
+ for ((slot, _) in chest.getAllItems()) {
val goal = BingoAPI.bingoGoals[slot.slotNumber] ?: continue
if (config.hideDoneDifficulty && goal.done) continue
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt
index 05104ce8a..b1d63a24d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RenderItemTipEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -101,20 +102,16 @@ class DungeonFinderFeatures {
val inventoryName = chest.getInventoryName()
if (inventoryName != "Party Finder") return
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- if (slot.stack == null) continue
+ for ((slot, stack) in chest.getUpperItems()) {
+ if (!stack.name.endsWith(" Party")) continue
- if (!slot.stack.name.endsWith(" Party")) continue
-
- if (config.markIneligibleGroups && slot.stack.getLore().any { ineligiblePattern.matches(it) }) {
+ if (config.markIneligibleGroups && stack.getLore().any { ineligiblePattern.matches(it) }) {
slot highlight LorenzColor.DARK_RED
continue
}
if (config.markPaidCarries) {
- val note = slot.stack.getLore().filter { notePattern.containsMatchIn(it) }.joinToString(" ")
+ val note = stack.getLore().filter { notePattern.containsMatchIn(it) }.joinToString(" ")
if (pricePattern.containsMatchIn(note) && carryPattern.containsMatchIn(note)) {
slot highlight LorenzColor.RED
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt
index 786719391..0fd475647 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
@@ -218,10 +219,7 @@ class CityProjectFeatures {
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- val stack = slot.stack ?: continue
+ for ((slot, stack) in chest.getUpperItems()) {
val lore = stack.getLore()
if (lore.isEmpty()) continue
val last = lore.last()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt
index 8ab53cb9c..c8eebc10a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -83,11 +84,7 @@ class GardenComposterInventoryFeatures {
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- val stack = slot.stack ?: continue
-
+ for ((slot, stack) in chest.getUpperItems()) {
if (stack.getLore().any { it == "§eClick to upgrade!" }) {
slot highlight LorenzColor.GOLD
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt
index f7576abba..c361c1888 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -85,10 +86,7 @@ class JacobFarmingContestsInventory {
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- val stack = slot.stack ?: continue
+ for ((slot, stack) in chest.getUpperItems()) {
if (stack.getLore().any { it == "§eClick to claim reward!" }) {
slot highlight LorenzColor.GREEN
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
index 3b8a709a5..9a8055139 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -36,11 +37,7 @@ class AuctionsHighlighter {
val chest = guiChest.inventorySlots as ContainerChest
if (chest.getInventoryName() != "Manage Auctions") return
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- val stack = slot.stack ?: continue
-
+ for ((slot, stack) in chest.getUpperItems()) {
val lore = stack.getLore()
if (lore.any { it == "§7Status: §aSold!" }) {
slot highlight LorenzColor.GREEN
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
index 161c8d947..e483bed91 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt
@@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+import at.hannibal2.skyhanni.utils.InventoryUtils.getLowerItems
import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
@@ -96,19 +97,14 @@ class HideNotClickableItems {
val chest = guiChest.inventorySlots as ContainerChest
val chestName = chest.getInventoryName()
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
-
- if (slot.slotNumber == slot.slotIndex) continue
- if (slot.stack == null) continue
-
- if (hide(chestName, slot.stack)) {
+ for ((_, stack) in chest.getLowerItems()) {
+ if (hide(chestName, stack)) {
val opacity = config.opacity
val color = LorenzColor.DARK_GRAY.addOpacity(opacity)
- slot.stack.background = color.rgb
+ stack.background = color.rgb
} else if (reverseColor && config.itemsGreenLine) {
val color = LorenzColor.GREEN.addOpacity(200)
- slot.stack.borderLine = color.rgb
+ stack.borderLine = color.rgb
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
index 5291797a4..1a88f1185 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -61,10 +62,8 @@ class QuickCraftFeatures {
if (event.gui !is GuiChest) return
val chest = event.gui.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
+ for ((slot, stack) in chest.getAllItems()) {
if (inventoryType.ignoreSlot(slot.slotNumber)) continue
- val stack = slot.stack ?: continue
if (stack.name == "§cQuick Crafting Slot") continue
if (needsQuickCraftConfirmation(stack)) {
val color = LorenzColor.DARK_GRAY.addOpacity(180)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt
index c771f7d42..fb6b837aa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
@@ -104,10 +105,7 @@ class BazaarApi {
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- val stack = slot.stack ?: continue
-
+ for ((slot, stack) in chest.getAllItems()) {
if (chest.inventorySlots.indexOf(slot) !in 9..44) {
continue
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt
index 165e1a5a5..781cfaf91 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarDataOrError
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -53,12 +54,8 @@ class BazaarOrderHelper {
val inventoryName = chest.getInventoryName()
if (!isBazaarOrderInventory(inventoryName)) return
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- if (slot.stack == null) continue
-
- bazaarItemNamePattern.matchMatcher(slot.stack.name) {
+ for ((slot, stack) in chest.getUpperItems()) {
+ bazaarItemNamePattern.matchMatcher(stack.name) {
val buyOrSell = group("type").let { (it == "BUY") to (it == "SELL") }
if (buyOrSell.let { !it.first && !it.second }) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt
index 8042f6f5c..4bf989c31 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt
@@ -31,6 +31,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName
+import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -96,11 +97,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) {
val dojoQuest = getQuest<DojoQuest>() ?: return
if (dojoQuest.state != QuestState.ACCEPTED) return
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- if (slot.slotNumber != slot.slotIndex) continue
- val stack = slot.stack ?: continue
-
+ for ((slot, stack) in chest.getUpperItems()) {
if (stack.name.contains(dojoQuest.dojoName)) {
slot highlight LorenzColor.AQUA
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt
index 17dfacbd8..cc489c777 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
@@ -117,10 +118,7 @@ object EnigmaSoulWaypoints {
val guiChest = event.gui
val chest = guiChest.inventorySlots as ContainerChest
- for (slot in chest.inventorySlots) {
- if (slot == null) continue
- val stack = slot.stack ?: continue
-
+ for ((slot, stack) in chest.getAllItems()) {
for (soul in trackedSouls) {
if (stack.displayName.removeColor().contains(soul)) {
slot highlight LorenzColor.DARK_PURPLE
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
index c0b5e04df..3566761b2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt
@@ -80,4 +80,26 @@ object InventoryUtils {
countItemsInLowerInventory { it.getInternalNameOrNull() == name }
fun isItemInInventory(name: NEUInternalName) = getAmountOfItemInInventory(name) > 0
+
+ fun ContainerChest.getUpperItems(): Map<Slot, ItemStack> = buildMap {
+ for ((slot, stack) in getAllItems()) {
+ if (slot.slotNumber != slot.slotIndex) continue
+ this[slot] = stack
+ }
+ }
+
+ fun ContainerChest.getLowerItems(): Map<Slot, ItemStack> = buildMap {
+ for ((slot, stack) in getAllItems()) {
+ if (slot.slotNumber == slot.slotIndex) continue
+ this[slot] = stack
+ }
+ }
+
+ fun ContainerChest.getAllItems(): Map<Slot, ItemStack> = buildMap {
+ for (slot in inventorySlots) {
+ if (slot == null) continue
+ val stack = slot.stack ?: continue
+ this[slot] = stack
+ }
+ }
}