diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-17 00:48:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-17 00:48:44 +0200 |
commit | c7b6a0683c5e578c3018b413c307c800b33b3943 (patch) | |
tree | 95d0d58a9f8119a63ee64564e56682fdbc90ce69 /src/main/java/at/hannibal2/skyhanni | |
parent | e65a4c1b4d8eb3a4b6870ea36ee606b08c8a4886 (diff) | |
download | skyhanni-c7b6a0683c5e578c3018b413c307c800b33b3943.tar.gz skyhanni-c7b6a0683c5e578c3018b413c307c800b33b3943.tar.bz2 skyhanni-c7b6a0683c5e578c3018b413c307c800b33b3943.zip |
Feature: cofl ah search item (#1743)
Co-authored-by: Äkwav <16632490+Ekwav@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt) | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt | 89 |
4 files changed, 100 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 4ae9ed824..2f3920a18 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -270,6 +270,8 @@ import at.hannibal2.skyhanni.features.inventory.ShiftClickNPCSell import at.hannibal2.skyhanni.features.inventory.SkyblockGuideHighlightFeature import at.hannibal2.skyhanni.features.inventory.StatsTuning import at.hannibal2.skyhanni.features.inventory.SuperCraftFeatures +import at.hannibal2.skyhanni.features.inventory.auctionhouse.AuctionHouseCopyUnderbidPrice +import at.hannibal2.skyhanni.features.inventory.auctionhouse.AuctionHouseOpenPriceWebsite import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarBestSellMethod import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarCancelledBuyOrderClipboard @@ -362,7 +364,6 @@ import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader import at.hannibal2.skyhanni.features.misc.compacttablist.TabListRenderer import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager -import at.hannibal2.skyhanni.features.misc.items.AuctionHouseCopyUnderbidPrice import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.features.misc.items.EstimatedWardrobePrice import at.hannibal2.skyhanni.features.misc.items.GlowingDroppedItems @@ -632,6 +633,7 @@ class SkyHanniMod { loadModule(ShiftClickBrewing()) loadModule(BazaarOpenPriceWebsite()) loadModule(AuctionHouseCopyUnderbidPrice()) + loadModule(AuctionHouseOpenPriceWebsite()) loadModule(AnvilCombineHelper()) loadModule(SeaCreatureMessageShortener()) loadModule(AshfangFreezeCooldown) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java index 3725eeb1c..21108095b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/AuctionHouseConfig.java @@ -49,4 +49,10 @@ public class AuctionHouseConfig { ) @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) public int copyUnderbidKeybind = Keyboard.KEY_NONE; + + @Expose + @ConfigOption(name = "Price Website", desc = "Adds a button to the Auction House that will open the item page in §csky.coflnet.com§7.") + @ConfigEditorBoolean + @FeatureToggle + public boolean openPriceWebsite = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt index 43ca734fc..9b7cab11a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.misc.items +package at.hannibal2.skyhanni.features.inventory.auctionhouse import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator @@ -31,7 +31,7 @@ class AuctionHouseCopyUnderbidPrice { ) private val allowedInventoriesPattern by patternGroup.pattern( "allowedinventories", - "(?:Auctions Browser|Manage Auctions|Auctions: \".*\"?)" + "Auctions Browser|Manage Auctions|Auctions: \".*\"?" ) @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt new file mode 100644 index 000000000..9f1cce065 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt @@ -0,0 +1,89 @@ +package at.hannibal2.skyhanni.features.inventory.auctionhouse + +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.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.OSUtils +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.entity.player.InventoryPlayer +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +class AuctionHouseOpenPriceWebsite { + + private val config get() = SkyHanniMod.feature.inventory.auctions + private var lastClick = SimpleTimeMark.farPast() + + private val patternGroup = RepoPattern.group("inventory.auctionhouse") + + /** + * REGEX-TEST: Auctions: "hyperion" + */ + private val ahSearchPattern by patternGroup.pattern( + "title.search", + "Auctions: \"(?<searchTerm>.*)\"?" + ) + + private var searchTerm = "" + private var displayItem: ItemStack? = null + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!isEnabled()) return + ahSearchPattern.matchMatcher(event.inventoryName) { + searchTerm = group("searchTerm").removeSuffix("\"").replace(" ", "%20") + displayItem = createDisplayItem() + } + } + + private fun createDisplayItem() = Utils.createItemStack( + "PAPER".asInternalName().getItemStack().item, + "§bPrice History", + "§7Click here to open", + "§7the price history", + "§7of §e$searchTerm", + "§7on §csky.coflnet.com" + ) + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + displayItem = null + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (!isEnabled()) return + if (event.inventory is InventoryPlayer) return + + if (event.slotNumber == 8) { + displayItem?.let { + event.replaceWith(it) + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!isEnabled()) return + displayItem ?: return + if (event.slotId != 8) return + event.isCanceled = true + if (lastClick.passedSince() > 0.3.seconds) { + val url = "https://sky.coflnet.com/api/mod/open/$searchTerm" + OSUtils.openBrowser(url) + lastClick = SimpleTimeMark.now() + } + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.openPriceWebsite +} |