diff options
author | NetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com> | 2023-10-15 08:52:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-15 14:52:24 +0200 |
commit | 4b7349f50ac1cdb14ac89fef0d697a6e943f586f (patch) | |
tree | d2dbf0d8a0f347c35d7db8b1e6611779d9fef8a7 /src/main/java/at | |
parent | 0303c7985ab1232182abed3c8f635679a6ac6531 (diff) | |
download | skyhanni-4b7349f50ac1cdb14ac89fef0d697a6e943f586f.tar.gz skyhanni-4b7349f50ac1cdb14ac89fef0d697a6e943f586f.tar.bz2 skyhanni-4b7349f50ac1cdb14ac89fef0d697a6e943f586f.zip |
Feature: Crimson Isle Fetch Quest Helper (#437)
Added Quest Item Helper. #437
Diffstat (limited to 'src/main/java/at')
4 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 84400ae2c..55a14df90 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -226,6 +226,7 @@ import at.hannibal2.skyhanni.features.mobs.AreaMiniBossFeatures import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.mobs.MobHighlight import at.hannibal2.skyhanni.features.mobs.SpawnTimers +import at.hannibal2.skyhanni.features.nether.QuestItemHelper import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazes import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazingSouls import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown @@ -594,6 +595,7 @@ class SkyHanniMod { loadModule(GlowingDroppedItems()) loadModule(DungeonTeammateOutlines()) loadModule(DungeonRankTabListColor()) + loadModule(QuestItemHelper()) loadModule(PlayerChatSymbols()) loadModule(FixNEUHeavyPearls()) loadModule(QuickCraftFeatures()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java index a6927b522..37888a1c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/CrimsonIsleConfig.java @@ -141,4 +141,10 @@ public class CrimsonIsleConfig { @ConfigEditorDropdown(values = {"Always", "Only With Hotkey", "Never"}) public int showLocation = 1; } + + @Expose + @ConfigOption(name = "Fetch Quest from Sacks", desc = "Gets the items from your sacks when you open a 'item fetch' daily quest in the town board.") + @ConfigEditorBoolean + @FeatureToggle + public boolean questdailyFetchItemsFromSacks = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 64bebee7e..9e2e4a7fa 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -285,6 +286,8 @@ object SackAPI { return sackData[item] ?: return SackItem(0, 0, -1) } + fun commandGetFromSacks(item: String, amount: Int) = LorenzUtils.sendCommandToServer("gfs $item $amount") + private fun saveSackData() { ProfileStorageData.sackProfiles?.sackContents = sackData SkyHanniMod.configManager.saveSackData("saving-data") 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 = ". (?<name>[\\w ]+) x(?<amount>\\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 +} |