Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Show unique hoppity eggs in the warp menu #2625

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,16 @@ 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
@FeatureToggle
martimavocado marked this conversation as resolved.
Show resolved Hide resolved
public boolean uniquesWarpMenuHideMax = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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.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 {
private val islandNamePattern by RepoPattern.pattern(
"inventory.warpmenu.island.name",
"^§[ab](?<name>[\\w ']+)(?:§7 - §b.*)?\$"
martimavocado marked this conversation as resolved.
Show resolved Hide resolved
)

private val collectedEggStorage: MutableMap<IslandType, MutableSet<LorenzVec>>
martimavocado marked this conversation as resolved.
Show resolved Hide resolved
get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations ?: mutableMapOf()

private val config get() = SkyHanniMod.feature.event.hoppityEggs

@SubscribeEvent
fun onTooltip(event: LorenzToolTipEvent) {
if (!config.uniquesWarpMenu) return
martimavocado marked this conversation as resolved.
Show resolved Hide resolved
if (!HoppityAPI.isHoppityEvent()) return
if (event.slot.inventory.name != "Fast Travel") return

islandNamePattern.matchMatcher(event.slot.stack.displayName) {
val island = when (val name = group("name")) {
"SkyBlock Hub" -> IslandType.HUB
"The Barn" -> IslandType.THE_FARMING_ISLANDS
else -> IslandType.getByNameOrNull(name) ?: return
}

val maxEggs = HoppityEggLocations.apiEggLocations[island]?.size ?: return
val collectedEggs = collectedEggStorage[island]?.size ?: 0
martimavocado marked this conversation as resolved.
Show resolved Hide resolved

if (collectedEggs == maxEggs && config.uniquesWarpMenuHideMax) return

event.toolTip.add(2, "§7Collected Eggs: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs")
}
}
}
Loading