diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-04-10 17:18:35 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-10 09:18:35 +0200 |
| commit | fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d (patch) | |
| tree | 034630ba350c42a5cfd582a2cfdc88bb15fb68cc /src/main/java/at/hannibal2/skyhanni/features/fame | |
| parent | 3397cc4474e3165865707182a5dcacf5bb4e68bd (diff) | |
| download | skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.tar.gz skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.tar.bz2 skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.zip | |
Backend: Remove some more deprecated functions and misc code cleanup (#1402)
Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fame')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt | 12 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt | 19 |
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)", |
