diff options
Diffstat (limited to 'src')
3 files changed, 55 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 2bfe65a49..345b3fb83 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 @@ -88,6 +88,12 @@ public class HoppityEggsConfig { 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 @FeatureToggle 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 d2a38831a..e25d725ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -127,6 +127,9 @@ public class ProfileSpecificStorage { @Expose public Map<String, Integer> rabbitCounts = new HashMap(); + + @Expose + 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 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 + } } |