Skip to content

Commit

Permalink
Fixed /gfs command counting to slayer profit tracker.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Dec 21, 2023
1 parent 3a309af commit b6d939a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent
Expand All @@ -9,10 +10,13 @@ import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getItemName
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.client.Minecraft
import net.minecraft.network.play.server.S0DPacketCollectItem
import net.minecraft.network.play.server.S2FPacketSetSlot
Expand All @@ -24,6 +28,10 @@ import kotlin.time.Duration.Companion.milliseconds
class OwnInventoryData {
private var itemAmounts = mapOf<NEUInternalName, Int>()
private var dirty = false
private val sackToInventoryChatPattern by RepoPattern.pattern(
"data.owninventory.chat.movedsacktoinventory",
"§aMoved §r§e\\d* (?<name>.*)§r§a from your Sacks to your inventory."
)

@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
fun onChatPacket(event: PacketEvent.ReceiveEvent) {
Expand Down Expand Up @@ -96,6 +104,14 @@ class OwnInventoryData {
ignoreItem(500.milliseconds) { true }
}

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
sackToInventoryChatPattern.matchMatcher(event.message) {
val name = group("name")
ignoreItem(500.milliseconds) { it.getItemName().contains(name) }
}
}

private fun ignoreItem(duration: Duration, condition: (NEUInternalName) -> Boolean) {
ignoredItemsUntil.add(IgnoredItem(condition, SimpleTimeMark.now() + duration))
}
Expand All @@ -109,7 +125,10 @@ class OwnInventoryData {
if (diffWorld < 3_000) return

ignoredItemsUntil.removeIf { it.blockedUntil.isInPast() }
if (ignoredItemsUntil.any { it.condition(internalName) }) return
if (ignoredItemsUntil.any { it.condition(internalName) }) {
// println("ignored: $internalName")
return
}

if (internalName.startsWith("MAP-")) return

Expand Down

0 comments on commit b6d939a

Please sign in to comment.