diff options
author | Phoebe <77941535+catgirlseraid@users.noreply.github.com> | 2024-05-17 20:51:54 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-17 10:51:54 +0200 |
commit | c9b76f791542eca8a256a042abc5ad73ec5e2cca (patch) | |
tree | 081f898ed85924fe9e7c1fdb20fad84e339f1ab1 | |
parent | ef235edc6a7312c2e3d529e35b610b561c45bc4e (diff) | |
download | skyhanni-c9b76f791542eca8a256a042abc5ad73ec5e2cca.tar.gz skyhanni-c9b76f791542eca8a256a042abc5ad73ec5e2cca.tar.bz2 skyhanni-c9b76f791542eca8a256a042abc5ad73ec5e2cca.zip |
Added time tower ending reminder (#1816)
Co-authored-by: SeRaid <77941535+SeRaid743@users.noreply.github.com>
2 files changed, 34 insertions, 2 deletions
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,13 +104,19 @@ 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 public ChocolateUpgradeWarningsConfig chocolateUpgradeWarnings = new ChocolateUpgradeWarningsConfig(); 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() |