From c9b76f791542eca8a256a042abc5ad73ec5e2cca Mon Sep 17 00:00:00 2001 From: Phoebe <77941535+catgirlseraid@users.noreply.github.com> Date: Fri, 17 May 2024 20:51:54 +1200 Subject: Added time tower ending reminder (#1816) Co-authored-by: SeRaid <77941535+SeRaid743@users.noreply.github.com> --- .../chocolatefactory/ChocolateFactoryConfig.java | 8 ++++++- .../ChocolateFactoryTimeTowerManager.kt | 28 +++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index fec747511..3f86dfefe 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -104,12 +104,18 @@ public class ChocolateFactoryConfig { public boolean showDuplicateTime = false; @Expose - @ConfigOption(name = "Time Tower Warning", desc = "Notification when you have a new time tower usage available and " + + @ConfigOption(name = "Time Tower Usage Warning", desc = "Notification when you have a new time tower usage available and " + "continuously warn when your time tower is full.") @ConfigEditorBoolean @FeatureToggle public boolean timeTowerWarning = false; + @Expose + @ConfigOption(name = "Time Tower Reminder", desc = "Notification a minute before the time tower ends.") + @ConfigEditorBoolean + @FeatureToggle + public boolean timeTowerReminder = true; + @Expose @ConfigOption(name = "Upgrade Warnings", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt index cf67d91d3..695d1d480 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt @@ -21,6 +21,7 @@ object ChocolateFactoryTimeTowerManager { private val profileStorage get() = ChocolateFactoryAPI.profileStorage private var lastTimeTowerWarning = SimpleTimeMark.farPast() + private var lastTimeTowerReminder = SimpleTimeMark.farPast() @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { @@ -33,6 +34,10 @@ object ChocolateFactoryTimeTowerManager { if (ChocolateFactoryAPI.inChocolateFactory) return + if (config.timeTowerReminder) { + timeTowerReminder() + } + val nextCharge = SimpleTimeMark(profileStorage.nextTimeTower) if (nextCharge.isInPast() && !nextCharge.isFarPast() && currentCharges() < maxCharges()) { @@ -92,11 +97,32 @@ object ChocolateFactoryTimeTowerManager { fun timeTowerActive(): Boolean { val currentTime = profileStorage?.lastDataSave ?: 0 - val endTime = profileStorage?.currentTimeTowerEnds ?: 0 + val endTime = timeTowerEnds() return endTime > currentTime } + private fun timeTowerEnds(): Long { + return profileStorage?.currentTimeTowerEnds ?: 0 + } + + private fun timeTowerReminder() { + if (lastTimeTowerReminder.passedSince() < 20.seconds) return + + val timeUntil = SimpleTimeMark(timeTowerEnds()).timeUntil() + if (timeUntil < 1.minutes && timeUntil.isPositive()) { + ChatUtils.clickableChat( + "§cYour Time Tower is about to end! " + + "Open the Chocolate Factory to avoid wasting the multiplier!", + onClick = { + HypixelCommands.chocolateFactory() + } + ) + SoundUtils.playBeepSound() + lastTimeTowerReminder = SimpleTimeMark.now() + } + } + fun timeTowerFullTimemark(): SimpleTimeMark { val profileStorage = profileStorage ?: return SimpleTimeMark.farPast() if (timeTowerFull()) return SimpleTimeMark.farPast() -- cgit