diff options
author | appable <enzospiacitelli@gmail.com> | 2024-05-29 00:42:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 09:42:08 +0200 |
commit | f8d12759270b23339c276f28863254bb84156686 (patch) | |
tree | bd090d9d3944fd6f3498700acc27b088ebbea184 /src/main/java/at/hannibal2/skyhanni/features/event | |
parent | 5c991d02019249a42d8221fe7605f87e46164bb0 (diff) | |
download | skyhanni-f8d12759270b23339c276f28863254bb84156686.tar.gz skyhanni-f8d12759270b23339c276f28863254bb84156686.tar.bz2 skyhanni-f8d12759270b23339c276f28863254bb84156686.zip |
Feature: reminder to open hoppity shop each year (#1843)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt | 51 |
1 files changed, 46 insertions, 5 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 199535279..aaa4c365d 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 @@ -5,30 +5,60 @@ 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.features.inventory.chocolatefactory.ChocolateFactoryAPI +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 at.hannibal2.skyhanni.utils.SkyblockSeason import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds object HoppityNpc { private val config get() = HoppityEggsManager.config + private var lastReminderSent = SimpleTimeMark.farPast() + private var hoppityYearOpened + get() = ChocolateFactoryAPI.profileStorage?.hoppityShopYearOpened ?: -1 + set(value) { + ChocolateFactoryAPI.profileStorage?.hoppityShopYearOpened = value + } + private var slotsToHighlight = mutableSetOf<Int>() 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 (!ChocolateFactoryAPI.isHoppityEvent()) return + if (lastReminderSent.passedSince() <= 30.seconds) return + + ChatUtils.clickableChat( + "New rabbits are available at §aHoppity's Shop§e! §c(Click to disable this reminder)", + onClick = { + disableReminder() + ChatUtils.chat("§eHoppity's Shop reminder disabled.") + }, + oneTimeClick = true + ) + + lastReminderSent = SimpleTimeMark.now() } @SubscribeEvent @@ -54,6 +84,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 +93,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 + } } |