From 5e5d684213e99e0a10289e6b594b9799ed83a110 Mon Sep 17 00:00:00 2001 From: Appability Date: Mon, 20 May 2024 00:34:46 -0700 Subject: [PATCH 1/6] reminder to open hoppity shop each year --- .../features/event/HoppityEggsConfig.java | 6 +++ .../storage/ProfileSpecificStorage.java | 3 ++ .../features/event/hoppity/HoppityNpc.kt | 46 +++++++++++++++++-- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java index 04c915ff0bdb..3ec48ca3ac4f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java @@ -87,6 +87,12 @@ public class HoppityEggsConfig { @FeatureToggle public boolean highlightHoppityShop = true; + @Expose + @ConfigOption(name = "Hoppity Shop Reminder", desc = "Reminds you to open the Hoppity Shop each year.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hoppityShopReminder = true; + @Expose @ConfigOption(name = "Time in Chat", desc = "When the Egglocator can't find an egg, show the time until the next Hoppity event or egg spawn.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index f08ffddd7004..6b8a445239da 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -120,6 +120,9 @@ public static class PositionChange { @Expose public String targetName = null; + + @Expose + public Integer hoppityShopYearOpened = -1; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 1995352798a8..071f9195c5d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -1,34 +1,59 @@ package at.hannibal2.skyhanni.features.event.hoppity +import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds object HoppityNpc { private val config get() = HoppityEggsManager.config + private val lastReminderSent = SimpleTimeMark.farPast() + private var hoppityYearOpened + get() = ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened ?: -1 + set(value) { + ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened = value + } + private var slotsToHighlight = mutableSetOf() private var inShop = false @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!isEnabled()) return if (event.inventoryName != "Hoppity") return + hoppityYearOpened = SkyBlockTime.now().year inShop = true } - private fun clear() { - inShop = false - slotsToHighlight.clear() + @SubscribeEvent + fun onSecondPassed(event: SecondPassedEvent) { + if (!isReminderEnabled()) return + if (ReminderUtils.isBusy()) return + if (hoppityYearOpened == SkyBlockTime.now().year) return + if (lastReminderSent.passedSince() > 30.seconds) return + + ChatUtils.clickableChat( + "New rabbits are available at §aHoppity's Shop§e! §c(Click to disable these reminders)", + onClick = { + disableReminder() + }, + oneTimeClick = true + ) } @SubscribeEvent @@ -54,6 +79,7 @@ object HoppityNpc { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!isHighlightEnabled()) return if (!inShop) return for (slot in InventoryUtils.getItemsInOpenChest()) { if (slot.slotIndex in slotsToHighlight) { @@ -62,5 +88,15 @@ object HoppityNpc { } } - fun isEnabled() = LorenzUtils.inSkyBlock && config.highlightHoppityShop + private fun isHighlightEnabled() = LorenzUtils.inSkyBlock && config.highlightHoppityShop + private fun isReminderEnabled() = LorenzUtils.inSkyBlock && config.hoppityShopReminder + + private fun clear() { + inShop = false + slotsToHighlight.clear() + } + + private fun disableReminder() { + config.hoppityShopReminder = false + } } From ea4e11fd18991fc30166f90a5df947a9afeaaa74 Mon Sep 17 00:00:00 2001 From: Appability Date: Thu, 23 May 2024 20:19:03 -0700 Subject: [PATCH 2/6] fix inverted logic --- .../skyhanni/features/event/hoppity/HoppityNpc.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 071f9195c5d2..0e629e15d596 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -23,7 +23,7 @@ object HoppityNpc { private val config get() = HoppityEggsManager.config - private val lastReminderSent = SimpleTimeMark.farPast() + private var lastReminderSent = SimpleTimeMark.farPast() private var hoppityYearOpened get() = ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened ?: -1 set(value) { @@ -45,15 +45,18 @@ object HoppityNpc { if (!isReminderEnabled()) return if (ReminderUtils.isBusy()) return if (hoppityYearOpened == SkyBlockTime.now().year) return - if (lastReminderSent.passedSince() > 30.seconds) return + if (lastReminderSent.passedSince() <= 30.seconds) return ChatUtils.clickableChat( "New rabbits are available at §aHoppity's Shop§e! §c(Click to disable these reminders)", onClick = { disableReminder() + ChatUtils.chat("§eReminders disabled.") }, oneTimeClick = true ) + + lastReminderSent = SimpleTimeMark.now() } @SubscribeEvent From 884ac9f13c37422799433f9831a689d8ef8b7bf0 Mon Sep 17 00:00:00 2001 From: appable Date: Thu, 23 May 2024 20:24:57 -0700 Subject: [PATCH 3/6] use chocolatefactoryapi profile storage Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 0e629e15d596..81e7aaf3b041 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -25,9 +25,9 @@ object HoppityNpc { private var lastReminderSent = SimpleTimeMark.farPast() private var hoppityYearOpened - get() = ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened ?: -1 + get() = ChocolateFactoryAPI.profileStorage?.hoppityShopYearOpened ?: -1 set(value) { - ProfileStorageData.profileSpecific?.chocolateFactory?.hoppityShopYearOpened = value + ChocolateFactoryAPI.profileStorage?.hoppityShopYearOpened = value } private var slotsToHighlight = mutableSetOf() From 9b547771b63cac212c9f6e1af4f59fa9d88418a6 Mon Sep 17 00:00:00 2001 From: Appability Date: Thu, 23 May 2024 20:30:05 -0700 Subject: [PATCH 4/6] fix imports --- .../at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 81e7aaf3b041..461fc6b3036f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.features.event.hoppity -import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -8,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore From 9828b047984af520611d0c0dba687343a1af45b0 Mon Sep 17 00:00:00 2001 From: Appability Date: Fri, 24 May 2024 12:54:16 -0700 Subject: [PATCH 5/6] add season check; stored value to null; clarify reminder chat messages --- .../skyhanni/config/storage/ProfileSpecificStorage.java | 2 +- .../hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 6b8a445239da..ad5f63adee54 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -122,7 +122,7 @@ public static class PositionChange { public String targetName = null; @Expose - public Integer hoppityShopYearOpened = -1; + public Integer hoppityShopYearOpened = null; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 461fc6b3036f..5fb3aa6eb61d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyBlockTime +import at.hannibal2.skyhanni.utils.SkyblockSeason import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -45,13 +46,14 @@ object HoppityNpc { if (!isReminderEnabled()) return if (ReminderUtils.isBusy()) return if (hoppityYearOpened == SkyBlockTime.now().year) return + if (SkyblockSeason.getCurrentSeason() != SkyblockSeason.SPRING) return if (lastReminderSent.passedSince() <= 30.seconds) return ChatUtils.clickableChat( - "New rabbits are available at §aHoppity's Shop§e! §c(Click to disable these reminders)", + "New rabbits are available at §aHoppity's Shop§e! §c(Click to disable this reminder)", onClick = { disableReminder() - ChatUtils.chat("§eReminders disabled.") + ChatUtils.chat("§eHoppity's Shop reminder disabled.") }, oneTimeClick = true ) From 8f5cb0205d1dd0ac23acf643e069f16cc5a837d1 Mon Sep 17 00:00:00 2001 From: appable Date: Sun, 26 May 2024 00:08:04 -0700 Subject: [PATCH 6/6] use ChocolateFactoryAPI.isHoppityEvent() Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 5fb3aa6eb61d..aaa4c365dd90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -46,7 +46,7 @@ object HoppityNpc { if (!isReminderEnabled()) return if (ReminderUtils.isBusy()) return if (hoppityYearOpened == SkyBlockTime.now().year) return - if (SkyblockSeason.getCurrentSeason() != SkyblockSeason.SPRING) return + if (!ChocolateFactoryAPI.isHoppityEvent()) return if (lastReminderSent.passedSince() <= 30.seconds) return ChatUtils.clickableChat(