forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Show unique hoppity eggs in the warp menu (hannibal002#2625)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
- Loading branch information
1 parent
77f2872
commit a0229f2
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |