diff options
Diffstat (limited to 'src/main/java/at')
3 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 64b331a08..e5ccf33f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -926,7 +926,7 @@ class SkyHanniMod { loadModule(GardenInventoryTooltipOverflow()) loadModule(SkillTooltip()) loadModule(MaxPurseItems()) - loadModule(SuperCraftFeatures()) + loadModule(SuperCraftFeatures) loadModule(InfernoMinionFeatures()) loadModule(LimboPlaytime()) loadModule(RareDropMessages()) diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt index 498d87d10..386f90965 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt @@ -6,11 +6,14 @@ import at.hannibal2.skyhanni.events.ItemAddEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SackChangeEvent import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent +import at.hannibal2.skyhanni.features.inventory.SuperCraftFeatures.craftedPattern import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.TimeLimitedSet import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds @@ -57,11 +60,12 @@ class ItemAddManager { for (sackChange in event.sackChanges) { val change = sackChange.delta - if (change > 0) { - val internalName = sackChange.internalName + val internalName = sackChange.internalName + if (change > 0 && internalName !in superCraftedItems) { Source.SACKS.addItem(internalName, change) } } + superCraftedItems.clear() } @SubscribeEvent @@ -83,11 +87,17 @@ class ItemAddManager { } private var lastDiceRoll = SimpleTimeMark.farPast() + private var superCraftedItems = TimeLimitedSet<NEUInternalName>(30.seconds) @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (diceRollChatPattern.matches(event.message)) { lastDiceRoll = SimpleTimeMark.now() } + craftedPattern.matchMatcher(event.message) { + val internalName = NEUInternalName.fromItemName(group("item")) + if (!SackAPI.sackListInternalNames.contains(internalName.asString())) return@matchMatcher + superCraftedItems.add(internalName) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt index 9d3f92104..c95533184 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt @@ -12,8 +12,8 @@ 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( +object SuperCraftFeatures { + val craftedPattern by RepoPattern.pattern( "inventory.supercrafting.craft.new", "§eYou Supercrafted §r§r§r§.(?<item>[^§]+)(?:§r§8x(?<amount>[\\d,]+))?§r§e!" ) |