From 3f5756012e01f5b79086ecd04b7d463079fe6e1b Mon Sep 17 00:00:00 2001 From: martimavocado Date: Mon, 30 Sep 2024 20:44:34 +0100 Subject: [PATCH 1/7] init --- .../features/event/hoppity/WarpMenuUniques.kt | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt 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 000000000000..a25d9cb204cc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -0,0 +1,39 @@ +package at.hannibal2.skyhanni.features.event.hoppity + +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](?[\\w ']+)(?:§7 - §b.*)?\$" + ) + + private val collectedEggStorage: MutableMap> + get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations ?: mutableMapOf() + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + 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 actualEggs = collectedEggStorage[island]?.size ?: 0 + + event.toolTip.add("§7Collected: ${if (actualEggs == maxEggs) "§a" else ""}$actualEggs/$maxEggs") + } + } +} From 10b119bd77b8c3598a9c86cbbda877f75f7f5f2a Mon Sep 17 00:00:00 2001 From: martimavocado Date: Mon, 30 Sep 2024 20:49:58 +0100 Subject: [PATCH 2/7] add config --- .../config/features/event/hoppity/HoppityEggsConfig.java | 6 ++++++ .../skyhanni/features/event/hoppity/WarpMenuUniques.kt | 9 +++++++-- 2 files changed, 13 insertions(+), 2 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 8bbaa962ca26..236a084f156f 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,10 @@ 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; } 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 index a25d9cb204cc..95464a11b644 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -1,5 +1,6 @@ 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 @@ -19,8 +20,12 @@ object WarpMenuUniques { private val collectedEggStorage: MutableMap> get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations ?: mutableMapOf() + private val config get() = SkyHanniMod.feature.event.hoppityEggs + @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { + if (!config.uniquesWarpMenu) return + if (!HoppityAPI.isHoppityEvent()) return if (event.slot.inventory.name != "Fast Travel") return islandNamePattern.matchMatcher(event.slot.stack.displayName) { @@ -31,9 +36,9 @@ object WarpMenuUniques { } val maxEggs = HoppityEggLocations.apiEggLocations[island]?.size ?: return - val actualEggs = collectedEggStorage[island]?.size ?: 0 + val collectedEggs = collectedEggStorage[island]?.size ?: 0 - event.toolTip.add("§7Collected: ${if (actualEggs == maxEggs) "§a" else ""}$actualEggs/$maxEggs") + event.toolTip.add("§7Collected: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs") } } } From ab1937c5f0ec03975dbccbfeb1553120a25adcc1 Mon Sep 17 00:00:00 2001 From: martimavocado Date: Mon, 30 Sep 2024 21:39:11 +0100 Subject: [PATCH 3/7] add hide on max --- .../config/features/event/hoppity/HoppityEggsConfig.java | 6 ++++++ .../skyhanni/features/event/hoppity/WarpMenuUniques.kt | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 236a084f156f..41bc9701f5df 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 @@ -217,4 +217,10 @@ public String toString() { @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 + 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 index 95464a11b644..679d523738a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -38,7 +38,9 @@ object WarpMenuUniques { val maxEggs = HoppityEggLocations.apiEggLocations[island]?.size ?: return val collectedEggs = collectedEggStorage[island]?.size ?: 0 - event.toolTip.add("§7Collected: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs") + if (collectedEggs == maxEggs && config.uniquesWarpMenuHideMax) return + + event.toolTip.add(2, "§7Collected Eggs: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs") } } } From 8d714177b1dfa95ece9fb3859da20b0cfb2da27b Mon Sep 17 00:00:00 2001 From: martimavocado Date: Wed, 9 Oct 2024 01:02:30 +0100 Subject: [PATCH 4/7] misc changes --- .../features/event/hoppity/HoppityEggsConfig.java | 1 - .../features/event/hoppity/WarpMenuUniques.kt | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 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 41bc9701f5df..3fd83db69655 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 @@ -221,6 +221,5 @@ public String toString() { @Expose @ConfigOption(name = "Hide when maxed", desc = "Stops the above feature from working when the island is complete.") @ConfigEditorBoolean - @FeatureToggle 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 index 679d523738a4..2bca519a0e1e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -5,6 +5,7 @@ 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 @@ -12,18 +13,25 @@ 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](?[\\w ']+)(?:§7 - §b.*)?\$" ) - private val collectedEggStorage: MutableMap> - get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations ?: mutableMapOf() + private val collectedEggStorage: MutableMap>? + 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 @@ -36,7 +44,7 @@ object WarpMenuUniques { } val maxEggs = HoppityEggLocations.apiEggLocations[island]?.size ?: return - val collectedEggs = collectedEggStorage[island]?.size ?: 0 + val collectedEggs = collectedEggStorage?.get(island)?.size ?: return if (collectedEggs == maxEggs && config.uniquesWarpMenuHideMax) return From f9f06b7df1686a7c21022a6bae8b36e33033913f Mon Sep 17 00:00:00 2001 From: martimavocado Date: Wed, 9 Oct 2024 02:09:55 +0100 Subject: [PATCH 5/7] handle hub only needing 15 locations --- .../skyhanni/features/event/hoppity/WarpMenuUniques.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 index 2bca519a0e1e..047afeca38e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -43,7 +43,9 @@ object WarpMenuUniques { else -> IslandType.getByNameOrNull(name) ?: return } - val maxEggs = HoppityEggLocations.apiEggLocations[island]?.size ?: return + val maxEggs = if (HoppityEggLocations.apiEggLocations[island]?.size != null) { + 15 + } else return val collectedEggs = collectedEggStorage?.get(island)?.size ?: return if (collectedEggs == maxEggs && config.uniquesWarpMenuHideMax) return From 60b309d90fb5151f884a8bdb40a33a16a1750221 Mon Sep 17 00:00:00 2001 From: martimavocado Date: Wed, 9 Oct 2024 02:12:05 +0100 Subject: [PATCH 6/7] handle dungeon hub, profiles with 0 collected eggs in an island --- .../skyhanni/features/event/hoppity/WarpMenuUniques.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index 047afeca38e7..01b880cd4c4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -42,11 +42,12 @@ object WarpMenuUniques { "The Barn" -> IslandType.THE_FARMING_ISLANDS else -> IslandType.getByNameOrNull(name) ?: return } + if (island == IslandType.DUNGEON_HUB) return val maxEggs = if (HoppityEggLocations.apiEggLocations[island]?.size != null) { 15 } else return - val collectedEggs = collectedEggStorage?.get(island)?.size ?: return + val collectedEggs = collectedEggStorage?.get(island)?.size ?: 0 if (collectedEggs == maxEggs && config.uniquesWarpMenuHideMax) return From 9edd06476d29534c6fe3a11065e237ad8a2d36f3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:25:02 +0200 Subject: [PATCH 7/7] code cleanup --- .../features/event/hoppity/WarpMenuUniques.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) 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 index 01b880cd4c4d..939dea1b702f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/WarpMenuUniques.kt @@ -21,7 +21,7 @@ object WarpMenuUniques { */ private val islandNamePattern by RepoPattern.pattern( "inventory.warpmenu.island.name", - "^§[ab](?[\\w ']+)(?:§7 - §b.*)?\$" + "§[ab](?[\\w ']+)(?:§7 - §b.*)?", ) private val collectedEggStorage: MutableMap>? @@ -36,22 +36,23 @@ object WarpMenuUniques { 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 - } - if (island == IslandType.DUNGEON_HUB) return + val name = islandNamePattern.matchMatcher(event.slot.stack.displayName) { + group("name") + } ?: return - val maxEggs = if (HoppityEggLocations.apiEggLocations[island]?.size != null) { - 15 - } else return - val collectedEggs = collectedEggStorage?.get(island)?.size ?: 0 + 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 (collectedEggs == maxEggs && config.uniquesWarpMenuHideMax) return + if (HoppityEggLocations.apiEggLocations[island]?.size == null) return + val maxEggs = 15 + val collectedEggs = collectedEggStorage?.get(island)?.size ?: 0 - event.toolTip.add(2, "§7Collected Eggs: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs") - } + if (collectedEggs >= maxEggs && config.uniquesWarpMenuHideMax) return + + event.toolTip.add(2, "§7Collected Hoppity Eggs: ${if (collectedEggs == maxEggs) "§a" else ""}$collectedEggs/$maxEggs") } }