summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fame
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fame')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt19
2 files changed, 9 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt
index 4f1e3b5ea..ca700e2b1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt
@@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -32,16 +32,11 @@ class AccountUpgradeReminder {
}
}
+ // TODO: Merge this logic with CityProjectFeatures reminder to reduce duplication
@SubscribeEvent
- fun onTick(event: LorenzTickEvent) {
+ fun onSecondPassed(event: SecondPassedEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (event.repeatSeconds(1)) {
- checkReminder()
- }
- }
- // TODO: Merge this logic with CityProjectFeatures reminder to reduce duplication
- private fun checkReminder() {
if (!isEnabled()) return
val playerSpecific = ProfileStorageData.playerSpecific ?: return
if (ReminderUtils.isBusy()) return
@@ -50,7 +45,6 @@ class AccountUpgradeReminder {
val upgrade = playerSpecific.currentAccountUpgrade ?: return
val nextCompletionTime = nextCompletionTime ?: return
if (!nextCompletionTime.isInPast()) return
-
if (lastReminderSend.passedSince() < 30.seconds) return
lastReminderSend = SimpleTimeMark.now()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt
index c2bfd586e..f5f45862e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt
@@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
-import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
@@ -38,12 +38,13 @@ import net.minecraft.client.gui.inventory.GuiEditSign
import net.minecraft.inventory.ContainerChest
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
class CityProjectFeatures {
private var display = emptyList<List<Any>>()
private var inInventory = false
- private var lastReminderSend = 0L
+ private var lastReminderSend = SimpleTimeMark.farPast()
private val patternGroup = RepoPattern.group("fame.projects")
private val contributeAgainPattern by patternGroup.pattern(
@@ -65,14 +66,7 @@ class CityProjectFeatures {
}
@SubscribeEvent
- fun onTick(event: LorenzTickEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (event.repeatSeconds(1)) {
- checkDailyReminder()
- }
- }
-
- private fun checkDailyReminder() {
+ fun onSecondPassed(event: SecondPassedEvent) {
if (!config.dailyReminder) return
val playerSpecific = ProfileStorageData.playerSpecific ?: return
if (ReminderUtils.isBusy()) return
@@ -81,9 +75,8 @@ class CityProjectFeatures {
if (playerSpecific.nextCityProjectParticipationTime == 0L) return
if (System.currentTimeMillis() <= playerSpecific.nextCityProjectParticipationTime) return
-
- if (lastReminderSend + 30_000 > System.currentTimeMillis()) return
- lastReminderSend = System.currentTimeMillis()
+ if (lastReminderSend.passedSince() < 30.seconds) return
+ lastReminderSend = SimpleTimeMark.now()
ChatUtils.clickableChat(
"Daily City Project Reminder! (Click here to disable this reminder)",