From 6c1c000ba4a27e30a4c141b9988b5204d1ccad2f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 7 Jul 2024 11:44:37 +0200 Subject: Hoppity and Chocolate being less annoying (#2196) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/event/hoppity/HoppityEggsManager.kt | 3 ++- .../skyhanni/features/event/hoppity/HoppityNpc.kt | 4 ++-- .../chocolatefactory/ChocolateFactoryBarnManager.kt | 21 +++++++++++++-------- .../chocolatefactory/ChocolateFactoryDataLoader.kt | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt index 37679bdbf..5e51a7693 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher +import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds @SkyHanniModule @@ -218,7 +219,7 @@ object HoppityEggsManager { private fun warn() { if (!config.warnUnclaimedEggs) return if (ReminderUtils.isBusy() && !config.warnWhileBusy) return - if (lastWarnTime.passedSince() < 30.seconds) return + if (lastWarnTime.passedSince() < 1.minutes) return lastWarnTime = now() val amount = HoppityEggType.entries.size 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 2ec98ccf6..877e161ef 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 @@ -18,7 +18,7 @@ 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 +import kotlin.time.Duration.Companion.minutes @SkyHanniModule object HoppityNpc { @@ -51,7 +51,7 @@ object HoppityNpc { if (ReminderUtils.isBusy()) return if (hoppityYearOpened == SkyBlockTime.now().year) return if (!ChocolateFactoryAPI.isHoppityEvent()) return - if (lastReminderSent.passedSince() <= 30.seconds) return + if (lastReminderSent.passedSince() <= 2.minutes) return ChatUtils.clickableChat( "New rabbits are available at §aHoppity's Shop§e! §c(Click to disable this reminder)", diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt index 82cd17339..31762ab2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory +import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsCompactChat import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager @@ -10,11 +11,9 @@ import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.seconds @SkyHanniModule object ChocolateFactoryBarnManager { @@ -28,11 +27,11 @@ object ChocolateFactoryBarnManager { */ private val rabbitCrashedPattern by ChocolateFactoryAPI.patternGroup.pattern( "rabbit.crushed", - "§c§lBARN FULL! §f\\D+ §7got §ccrushed§7! §6\\+(?[\\d,]+) Chocolate" + "§c§lBARN FULL! §f\\D+ §7got §ccrushed§7! §6\\+(?[\\d,]+) Chocolate", ) var barnFull = false - private var lastBarnFullWarning = SimpleTimeMark.farPast() + private var sentBarnFullWarning = false @SubscribeEvent fun onChat(event: LorenzChatEvent) { @@ -41,7 +40,7 @@ object ChocolateFactoryBarnManager { HoppityEggsManager.newRabbitFound.matchMatcher(event.message) { val profileStorage = profileStorage ?: return profileStorage.currentRabbits += 1 - trySendBarnFullMessage() + trySendBarnFullMessage(inventory = false) HoppityEggsManager.shareWaypointPrompt() } @@ -64,7 +63,12 @@ object ChocolateFactoryBarnManager { } } - fun trySendBarnFullMessage() { + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + sentBarnFullWarning = false + } + + fun trySendBarnFullMessage(inventory: Boolean) { if (!ChocolateFactoryAPI.isEnabled()) return if (config.barnCapacityThreshold <= 0) { @@ -79,7 +83,9 @@ object ChocolateFactoryBarnManager { barnFull = remainingSpace <= config.barnCapacityThreshold if (!barnFull) return - if (lastBarnFullWarning.passedSince() < 30.seconds) return + if (inventory && sentBarnFullWarning) return + + sentBarnFullWarning = true if (profileStorage.maxRabbits == -1) { ChatUtils.clickableChat( @@ -99,7 +105,6 @@ object ChocolateFactoryBarnManager { "§eClick to run /cf!", ) SoundUtils.playBeepSound() - lastBarnFullWarning = SimpleTimeMark.now() } fun barnStatus(): String { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt index 5dd8a52d3..3724dbc53 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt @@ -279,7 +279,7 @@ object ChocolateFactoryDataLoader { item.getLore().matchFirst(barnAmountPattern) { profileStorage.currentRabbits = group("rabbits").formatInt() profileStorage.maxRabbits = group("max").formatInt() - ChocolateFactoryBarnManager.trySendBarnFullMessage() + ChocolateFactoryBarnManager.trySendBarnFullMessage(inventory = true) } } -- cgit