diff options
author | Zachary Jaser <76439587+Zickles@users.noreply.github.com> | 2024-03-04 16:11:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-04 22:11:22 +0100 |
commit | a8fe4fcd86b0abd646b719134f5606908cd516af (patch) | |
tree | 9834bd0791feac9f96d5ed273d35af9b674e994a /src/main | |
parent | 16facf4a91651c709e4c78e7b3f2c9973560feab (diff) | |
download | skyhanni-a8fe4fcd86b0abd646b719134f5606908cd516af.tar.gz skyhanni-a8fe4fcd86b0abd646b719134f5606908cd516af.tar.bz2 skyhanni-a8fe4fcd86b0abd646b719134f5606908cd516af.zip |
[Feat] Gfs message after supercrafting (#1097)
Diffstat (limited to 'src/main')
3 files changed, 39 insertions, 0 deletions
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§.(?<item>[^§]+)(?:§r§8x(?<amount>\\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)) + } + } +} |