diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-02 20:43:28 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-02-02 20:43:28 +0100 |
commit | 9484d930bd52ead1af076fc251aed691226ceee5 (patch) | |
tree | c95e5ce19b7f21dd725877de260cec4906d11e6b /src/main/java/at/hannibal2/skyhanni/features | |
parent | 7b329087dc47842e2a8337e650e6c037230da7ba (diff) | |
download | skyhanni-9484d930bd52ead1af076fc251aed691226ceee5.tar.gz skyhanni-9484d930bd52ead1af076fc251aed691226ceee5.tar.bz2 skyhanni-9484d930bd52ead1af076fc251aed691226ceee5.zip |
Prepare for bingo stuff.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
3 files changed, 21 insertions, 50 deletions
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 11994a0c8..7afe83e2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -193,7 +193,7 @@ class HideNotClickableItems { } } - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be put into the potion bag!" return true } @@ -227,7 +227,7 @@ class HideNotClickableItems { private fun hidePotionBag(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("Potion Bag")) return false - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be put into the potion bag!" return true } @@ -242,7 +242,7 @@ class HideNotClickableItems { private fun hideFishingBag(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("Fishing Bag")) return false - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be put into the fishing bag!" return true } @@ -257,7 +257,7 @@ class HideNotClickableItems { private fun hideSackOfSacks(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("Sack of Sacks")) return false - if (isSkyBlockMenuItem(stack)) return false + if (ItemUtils.isSkyBlockMenuItem(stack)) return false val name = stack.cleanName() reverseColor = true @@ -270,7 +270,7 @@ class HideNotClickableItems { private fun hideAccessoryBag(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("Accessory Bag") && !chestName.startsWith("Accessory Bag (")) return false - if (isSkyBlockMenuItem(stack)) return false + if (ItemUtils.isSkyBlockMenuItem(stack)) return false reverseColor = true if (stack.getLore().any { it.contains("ACCESSORY") }) return false @@ -287,7 +287,7 @@ class HideNotClickableItems { return true } - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be traded!" return true } @@ -316,7 +316,7 @@ class HideNotClickableItems { name = name.substring(0, name.length - amountText.length) } - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be sold at the NPC!" return true } @@ -343,7 +343,7 @@ class HideNotClickableItems { private fun hideInStorage(chestName: String, stack: ItemStack): Boolean { if (!chestName.contains("Ender Chest") && !chestName.contains("Backpack") && chestName != "Storage") return false - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be put into the storage!" return true } @@ -376,7 +376,7 @@ class HideNotClickableItems { } } - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { hideReason = "The SkyBlock Menu cannot be salvaged!" return true } @@ -400,7 +400,7 @@ class HideNotClickableItems { if (!bazaarInventory && !auctionHouseInventory) return false reverseColor = true - if (isSkyBlockMenuItem(stack)) { + if (ItemUtils.isSkyBlockMenuItem(stack)) { if (bazaarInventory) hideReason = "The SkyBlock Menu is not a Bazaar Product!" if (auctionHouseInventory) hideReason = "The SkyBlock Menu cannot be auctioned!" return true @@ -435,6 +435,4 @@ class HideNotClickableItems { if (result) hideReason = "This item cannot be auctioned!" return result } - - private fun isSkyBlockMenuItem(stack: ItemStack): Boolean = stack.getInternalName() == "SKYBLOCK_MENU" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt index f2b188787..088836401 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionCounter.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi import at.hannibal2.skyhanni.features.bazaar.BazaarData +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -62,9 +63,9 @@ class CollectionCounter { val apiName = data.apiName if (!apiCollectionData.contains(apiName)) { if (apiCollectionData.isEmpty()) { - LorenzUtils.chat("§c[SkyHanni] Collection data not loaded! (API down?)") + LorenzUtils.chat("§c[SkyHanni] No Collection Data! API down?") } else { - LorenzUtils.chat("§c[SkyHanni] Item $name is not in collection data!") + LorenzUtils.chat("§c[SkyHanni] Item $name is not in the collection data!") } return } @@ -104,18 +105,8 @@ class CollectionCounter { display = "$itemName collection: §e$format $gainText" } - private fun countCurrentlyInInventory(): Int { - var currentlyInInventory = 0 - val player = Minecraft.getMinecraft().thePlayer - for (stack in player.inventory.mainInventory) { - if (stack == null) continue - val internalName = stack.getInternalName() - if (internalName == itemApiName) { - currentlyInInventory += stack.stackSize - } - } - return currentlyInInventory - } + private fun countCurrentlyInInventory() = + InventoryUtils.countItemsInLowerInventory { it.getInternalName() == itemApiName } } @SubscribeEvent @@ -168,7 +159,9 @@ class CollectionCounter { @SubscribeEvent fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { val profileData = event.profileData - val collection = profileData["collection"].asJsonObject + + //new profiles don't have any collections + val collection = profileData["collection"]?.asJsonObject ?: return apiCollectionData.clear() for (entry in collection.entrySet()) { 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 5d051b5d2..e8e2acce7 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 @@ -12,16 +12,12 @@ import at.hannibal2.skyhanni.features.nether.reputationhelper.dailykuudra.Kuudra import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.* import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMiniBoss import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.highlight -import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.client.event.RenderWorldLastEvent @@ -66,15 +62,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { if (fishQuest.state != QuestState.ACCEPTED && fishQuest.state != QuestState.READY_TO_COLLECT) return val fishName = fishQuest.fishName - var currentlyInInventory = 0 - val player = Minecraft.getMinecraft().thePlayer - for (stack in player.inventory.mainInventory) { - if (stack == null) continue - val name = stack.name ?: continue - if (name.contains(fishName)) { - currentlyInInventory += stack.stackSize - } - } + val currentlyInInventory = InventoryUtils.countItemsInLowerInventory { it.name?.contains(fishName) ?: false } val diff = currentlyInInventory - latestTrophyFishInInventory if (diff < 1) return latestTrophyFishInInventory = currentlyInInventory @@ -170,15 +158,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { val itemName = fetchQuest.itemName - val player = Minecraft.getMinecraft().thePlayer - var count = 0 - for (stack in player.inventory.mainInventory) { - if (stack == null) continue - val name = stack.name ?: continue - if (name.contains(itemName)) { - count += stack.stackSize - } - } + val count = InventoryUtils.countItemsInLowerInventory { it.name?.contains(itemName) ?: false } updateProcessQuest(fetchQuest, count) } |