From 4b7349f50ac1cdb14ac89fef0d697a6e943f586f Mon Sep 17 00:00:00 2001 From: NetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com> Date: Sun, 15 Oct 2023 08:52:24 -0400 Subject: Feature: Crimson Isle Fetch Quest Helper (#437) Added Quest Item Helper. #437 --- .../skyhanni/features/nether/QuestItemHelper.kt | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/nether') diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt new file mode 100644 index 000000000..e7c5b0950 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/QuestItemHelper.kt @@ -0,0 +1,43 @@ +package at.hannibal2.skyhanni.features.nether + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.hours + +class QuestItemHelper { + private val config get() = SkyHanniMod.feature.crimsonIsle + + private val itemCollectionPattern = ". (?[\\w ]+) x(?\\d+)".toPattern() + private var questItem = "" + private var questAmount = 0 + private var lastSentMessage = SimpleTimeMark.farPast() + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!isEnabled()) return + if (event.inventoryName != "Fetch") return + if (lastSentMessage.passedSince() < 1.hours) return + items@ for ((_, item) in event.inventoryItems) { + itemCollectionPattern.matchMatcher(item.displayName.removeColor()) { + if (!matches()) continue@items + questItem = group("name") + questAmount = group("amount").toInt() + LorenzUtils.clickableChat( + "§e[SkyHanni] Get x$questAmount $questItem from sacks", + "gfs $questItem $questAmount" + ) + lastSentMessage = SimpleTimeMark.now() + break@items + } + } + } + + fun isEnabled() = IslandType.CRIMSON_ISLE.isInIsland() && config.questdailyFetchItemsFromSacks +} -- cgit