Skip to content

Commit

Permalink
Feature: Show unique hoppity eggs in the warp menu (hannibal002#2625)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
martimavocado and hannibal002 authored Oct 9, 2024
1 parent 77f2872 commit a0229f2
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,15 @@ public String toString() {
@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;
}
Original file line number Diff line number Diff line change
@@ -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")
}
}

0 comments on commit a0229f2

Please sign in to comment.