From a8fe4fcd86b0abd646b719134f5606908cd516af Mon Sep 17 00:00:00 2001 From: Zachary Jaser <76439587+Zickles@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:11:22 -0500 Subject: [Feat] Gfs message after supercrafting (#1097) --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 ++ .../features/inventory/GetFromSackConfig.java | 6 +++++ .../features/inventory/SuperCraftFeatures.kt | 31 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c410b6e96..5ce9d298c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -222,6 +222,7 @@ import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment 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.bazaar.BazaarApi import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarBestSellMethod import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarCancelledBuyOrderClipboard @@ -756,6 +757,7 @@ class SkyHanniMod { loadModule(SkillTooltip()) loadModule(QuiverNotification) loadModule(MaxPurseItems()) + loadModule(SuperCraftFeatures()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java index af6942176..98cc5c9b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java @@ -17,4 +17,10 @@ public class GetFromSackConfig { @ConfigOption(name = "Bazaar GfS", desc = "If you don't have enough items in sack get a prompt to buy them from bazaar.") @ConfigEditorBoolean public boolean bazaarGFS = false; + + @Expose + @ConfigOption(name = "Super Craft GfS", desc = "Send a clickable message after supercrafting an item that grabs the item from your sacks when clicked.") + @ConfigEditorBoolean + @FeatureToggle + public boolean superCraftGFS = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt new file mode 100644 index 000000000..85b6296b5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.GetFromSackAPI +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.PrimitiveItemStack +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class SuperCraftFeatures { + private val craftedPattern by RepoPattern.pattern( + "inventory.supercrafting.craft", + "§eYou Supercrafted §r§r§r§.(?[^§]+)(?:§r§8x(?\\d+))?§r§e!" + ) + private val config get() = SkyHanniMod.feature.inventory.gfs + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!config.superCraftGFS) return + val (internalName, amount) = craftedPattern.matchMatcher(event.message) { + NEUInternalName.fromItemName(this.group("item")) to (this.group("amount")?.toInt() ?: 1) + } ?: return + if (!GetFromSackAPI.sackListInternalNames.contains(internalName.asString())) return + DelayedRun.runNextTick { + GetFromSackAPI.getFromChatMessageSackItems(PrimitiveItemStack(internalName, amount)) + } + } +} -- cgit