diff options
author | martimavocado <39881008+martimavocado@users.noreply.github.com> | 2024-10-09 09:26:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-09 10:26:08 +0200 |
commit | a0229f243df1a158543e8b33923c839e7a017746 (patch) | |
tree | 3423174c73449412d6925b804da5c1074b760382 /src/main | |
parent | 77f2872d9502f08b69e23d826b0ebd39d76d3c7e (diff) | |
download | skyhanni-a0229f243df1a158543e8b33923c839e7a017746.tar.gz skyhanni-a0229f243df1a158543e8b33923c839e7a017746.tar.bz2 skyhanni-a0229f243df1a158543e8b33923c839e7a017746.zip |
Feature: Show unique hoppity eggs in the warp menu (#2625)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java | 11 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt | 58 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java index 8bbaa962c..3fd83db69 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java @@ -211,4 +211,15 @@ public class HoppityEggsConfig { @ConfigEditorBoolean @FeatureToggle public boolean petWarning = false; + + @Expose + @ConfigOption(name = "Show uniques in Warp Menu", desc = "Shows your unique eggs in the Warp Menu during the hoppity event.") + @ConfigEditorBoolean + @FeatureToggle + public boolean uniquesWarpMenu = true; + + @Expose + @ConfigOption(name = "Hide when maxed", desc = "Stops the above feature from working when the island is complete.") + @ConfigEditorBoolean + public boolean uniquesWarpMenuHideMax = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt new file mode 100644 index 000000000..939dea1b7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -0,0 +1,58 @@ +package at.hannibal2.skyhanni.features.event.hoppity + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object WarpMenuUniques { + + /** + * REGEX-TEST: §bSkyBlock Hub + * REGEX-TEST: §aThe Barn§7 - §bSpawn + * REGEX-TEST: §aCrystal Hollows§7 - §bEntrance + */ + private val islandNamePattern by RepoPattern.pattern( + "inventory.warpmenu.island.name", + "§[ab](?<name>[\\w ']+)(?:§7 - §b.*)?", + ) + + private val collectedEggStorage: MutableMap<IslandType, MutableSet<LorenzVec>>? + get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations + + private val config get() = SkyHanniMod.feature.event.hoppityEggs + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.uniquesWarpMenu) return + if (!HoppityAPI.isHoppityEvent()) return + if (event.slot.inventory.name != "Fast Travel") return + + val name = islandNamePattern.matchMatcher(event.slot.stack.displayName) { + group("name") + } ?: return + + val island = when (name) { + "SkyBlock Hub" -> IslandType.HUB + "The Barn" -> IslandType.THE_FARMING_ISLANDS + else -> IslandType.getByNameOrNull(name) ?: return + } + if (island == IslandType.DUNGEON_HUB) return + + if (HoppityEggLocations.apiEggLocations[island]?.size == null) return + val maxEggs = 15 + val collectedEggs = collectedEggStorage?.get(island)?.size ?: 0 + + if (collectedEggs >= maxEggs && config.uniquesWarpMenuHideMax) return + + event.toolTip.add(2, "§7Collected Hoppity Eggs: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs") + } +} |