diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-01-11 19:26:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-11 19:26:06 +0100 |
commit | 844e6272ebba1989dbabe971910978570d7a5c58 (patch) | |
tree | 0779182f03461933adb269b3c593f7652401cc34 | |
parent | 98cae88540ebff20202cbd12a4e5aa82a17d2efd (diff) | |
download | skyhanni-844e6272ebba1989dbabe971910978570d7a5c58.tar.gz skyhanni-844e6272ebba1989dbabe971910978570d7a5c58.tar.bz2 skyhanni-844e6272ebba1989dbabe971910978570d7a5c58.zip |
Feature: ShiftClickNPCSell (#907)
Option to makes normal clicks to shift clicks in equipment inventory. #907
4 files changed, 69 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 0551554cd..f93a36c48 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -209,6 +209,7 @@ import at.hannibal2.skyhanni.features.inventory.QuickCraftFeatures import at.hannibal2.skyhanni.features.inventory.RngMeterInventory import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment +import at.hannibal2.skyhanni.features.inventory.ShiftClickNPCSell import at.hannibal2.skyhanni.features.inventory.SkyBlockLevelGuideHelper import at.hannibal2.skyhanni.features.inventory.StatsTuning import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayHelper @@ -235,6 +236,7 @@ import at.hannibal2.skyhanni.features.misc.FixNEUHeavyPearls import at.hannibal2.skyhanni.features.misc.HideArmor import at.hannibal2.skyhanni.features.misc.InGameDateDisplay import at.hannibal2.skyhanni.features.misc.JoinCrystalHollows +import at.hannibal2.skyhanni.features.misc.LesserOrbHider import at.hannibal2.skyhanni.features.misc.LimboTimeTracker import at.hannibal2.skyhanni.features.misc.LockMouseLook import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager @@ -255,7 +257,6 @@ import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration import at.hannibal2.skyhanni.features.misc.SuperpairsClicksAlert import at.hannibal2.skyhanni.features.misc.TimeFeatures import at.hannibal2.skyhanni.features.misc.TpsCounter -import at.hannibal2.skyhanni.features.misc.LesserOrbHider import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader import at.hannibal2.skyhanni.features.misc.compacttablist.TabListRenderer @@ -517,6 +518,7 @@ class SkyHanniMod { loadModule(SoopyGuessBurrow()) loadModule(DianaProfitTracker) loadModule(MythologicalCreatureTracker) + loadModule(ShiftClickNPCSell) loadModule(HighlightJerries()) loadModule(TheGreatSpook()) loadModule(GriffinBurrowHelper) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 48be602a3..0aed8ec3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -9,7 +9,6 @@ import io.github.moulberry.moulconfig.annotations.Category; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; import io.github.moulberry.moulconfig.annotations.ConfigOption; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -184,9 +183,15 @@ public class InventoryConfig { public boolean copyUnderbidPrice = false; @Expose - @ConfigOption(name = "Shift Click Equipment", desc = "Makes normal clicks to shift clicks in equipment inventory") + @ConfigOption(name = "Shift Click Equipment", desc = "Makes normal clicks to shift clicks in equipment inventory.") @ConfigEditorBoolean @FeatureToggle public boolean shiftClickForEquipment = false; + @Expose + @ConfigOption(name = "Shift Click NPC sell", desc = "Makes normal clicks to shift clicks in npc inventory for selling.") + @ConfigEditorBoolean + @FeatureToggle + public boolean shiftClickNPCSell = false; + } 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 5a563c254..aa93dfd72 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.borderLine import at.hannibal2.skyhanni.data.jsonobjects.repo.HideNotClickableItemsJson import at.hannibal2.skyhanni.data.jsonobjects.repo.HideNotClickableItemsJson.SalvageFilter -import at.hannibal2.skyhanni.data.jsonobjects.repo.MultiFilterJson import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bazaar.BazaarApi @@ -49,16 +48,12 @@ class HideNotClickableItems { private val hideNpcSellFilter = MultiFilter() private val hideInStorageFilter = MultiFilter() - private val tradeNpcFilter = MultiFilter() private val itemsToSalvage = mutableListOf<String>() private val hidePlayerTradeFilter = MultiFilter() private val notAuctionableFilter = MultiFilter() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<MultiFilterJson>("TradeNpcs") - tradeNpcFilter.load(data) - val hideNotClickable = event.getConstant<HideNotClickableItemsJson>("HideNotClickableItems") hideNpcSellFilter.load(hideNotClickable.hide_npc_sell) hideInStorageFilter.load(hideNotClickable.hide_in_storage) @@ -175,7 +170,7 @@ class HideNotClickableItems { reverseColor = false return when { - hideNpcSell(chestName, stack) -> true + hideNpcSell(stack) -> true hideInStorage(chestName, stack) -> true hideSalvage(chestName, stack) -> true hidePlayerTrade(chestName, stack) -> true @@ -260,7 +255,7 @@ class HideNotClickableItems { "BRACELET" ) for (type in list) { - if (stack.getLore().any { it.contains("§l") && it.contains(type) }) {//todo use item api + if (stack.getLore().any { it.contains("§l") && it.contains(type) }) {// todo use item api reverseColor = true return false } @@ -289,7 +284,7 @@ class HideNotClickableItems { private fun hidePrivateIslandChest(chestName: String, stack: ItemStack): Boolean { if (chestName != "Chest" && chestName != "Large Chest") return false - //TODO make check if player is on private island + // TODO make check if player is on private island if (!ItemUtils.isSoulBound(stack)) return false @@ -378,8 +373,8 @@ class HideNotClickableItems { return result } - private fun hideNpcSell(chestName: String, stack: ItemStack): Boolean { - if (!tradeNpcFilter.match(chestName)) return false + private fun hideNpcSell(stack: ItemStack): Boolean { + if (!ShiftClickNPCSell.inInventory) return false if (VisitorAPI.inInventory) return false reverseColor = true diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt new file mode 100644 index 000000000..db1375b75 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt @@ -0,0 +1,54 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object ShiftClickNPCSell { + + private val config get() = SkyHanniMod.feature.inventory.shiftClickNPCSell + + private val sellSlot = 49 + private val lastLoreLineOfSellPattern by RepoPattern.pattern( + "inventory.npc.sell.lore", + "§7them to this Shop!|§eClick to buyback!" + ) + + var inInventory = false + private set + + fun isEnabled() = LorenzUtils.inSkyBlock && config + + @SubscribeEvent + fun onOpen(event: InventoryFullyOpenedEvent) { + if (!LorenzUtils.inSkyBlock) return + inInventory = lastLoreLineOfSellPattern.matches(event.inventoryItems[sellSlot]?.getLore()?.lastOrNull() ?: "") + } + + @SubscribeEvent + fun onClose(event: InventoryCloseEvent) { + inInventory = false + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!isEnabled()) return + if (!inInventory) return + + val slot = event.slot ?: return + + if (slot.slotNumber == slot.slotIndex) return + + event.isCanceled = true + Minecraft.getMinecraft().playerController.windowClick( + event.container.windowId, event.slot.slotNumber, event.clickedButton, 1, Minecraft.getMinecraft().thePlayer + ) + } +} |