aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-05-13 17:15:22 +0200
committerGitHub <noreply@github.com>2024-05-13 17:15:22 +0200
commit2cad7c87e85afa94465ed9a79cec4a20b303b26f (patch)
treebb4b7a6335274d2174805bf08be20d1dc10b4d0e /src/main/java/at/hannibal2/skyhanni
parent4a2b33c457e253faba78baa489be16778032281a (diff)
downloadskyhanni-2cad7c87e85afa94465ed9a79cec4a20b303b26f.tar.gz
skyhanni-2cad7c87e85afa94465ed9a79cec4a20b303b26f.tar.bz2
skyhanni-2cad7c87e85afa94465ed9a79cec4a20b303b26f.zip
Fix: Supercrafted Items in Profit Trackers (#1784)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt4
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!"
)