diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-03-25 00:46:00 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-24 14:46:00 +0100 |
commit | d6d899e8929e8caeb40e2099d13dd3425129d5e8 (patch) | |
tree | c7e9bdd74f4724f567863aff6ab9e7ce721d89c2 /src/main/java | |
parent | 4300af278a7a6f5124c9164998d132774a9f0a9c (diff) | |
download | skyhanni-d6d899e8929e8caeb40e2099d13dd3425129d5e8.tar.gz skyhanni-d6d899e8929e8caeb40e2099d13dd3425129d5e8.tar.bz2 skyhanni-d6d899e8929e8caeb40e2099d13dd3425129d5e8.zip |
Fix: Serverid error (#1262)
Diffstat (limited to 'src/main/java')
5 files changed, 18 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 9eb2aa5e7..3e8d0b756 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -95,7 +95,7 @@ class HypixelData { var bingo = false var profileName = "" - var joinedWorld = 0L + var joinedWorld = SimpleTimeMark.farPast() var skyBlockArea = "?" @@ -119,6 +119,7 @@ class HypixelData { fun checkCurrentServerId() { if (!LorenzUtils.inSkyBlock) return + if (LorenzUtils.lastWorldSwitch.passedSince() < 1.seconds) return ScoreboardData.sidebarLinesFormatted.forEach { serverIdScoreboardPattern.matchMatcher(it) { @@ -213,7 +214,7 @@ class HypixelData { inLimbo = false inLobby = false locraw.forEach { locraw[it.key] = "" } - joinedWorld = System.currentTimeMillis() + joinedWorld = SimpleTimeMark.now() serverId = null } diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index 18a8d2841..edc07287a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -25,6 +25,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds class OwnInventoryData { @@ -133,12 +134,10 @@ class OwnInventoryData { class IgnoredItem(val condition: (NEUInternalName) -> Boolean, val blockedUntil: SimpleTimeMark) private fun addItem(internalName: NEUInternalName, add: Int) { - val diffWorld = System.currentTimeMillis() - LorenzUtils.lastWorldSwitch - if (diffWorld < 3_000) return + if (LorenzUtils.lastWorldSwitch.passedSince() < 3.seconds) return ignoredItemsUntil.removeIf { it.blockedUntil.isInPast() } if (ignoredItemsUntil.any { it.condition(internalName) }) { -// println("ignored: $internalName") return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index e513ff98f..82914c66f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SackDataUpdateEvent -import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptedEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent @@ -437,8 +436,9 @@ class GardenVisitorFeatures { update() logger.log("New visitor detected: '$name'") + val recentWorldSwitch = LorenzUtils.lastWorldSwitch.passedSince() < 2.seconds - if (config.notificationTitle && System.currentTimeMillis() > LorenzUtils.lastWorldSwitch + 2_000) { + if (config.notificationTitle && !recentWorldSwitch) { LorenzUtils.sendTitle("§eNew Visitor", 5.seconds) } if (config.notificationChat) { @@ -446,7 +446,7 @@ class GardenVisitorFeatures { ChatUtils.chat("$displayName §eis visiting your garden!") } - if (System.currentTimeMillis() > LorenzUtils.lastWorldSwitch + 2_000) { + if (!recentWorldSwitch) { if (name.removeColor().contains("Jerry")) { logger.log("Jerry!") ItemBlink.setBlink(NEUItems.getItemStackOrNull("JERRY;4"), 5_000) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index b5f7dc87c..653290395 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -33,6 +33,7 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard +import kotlin.time.Duration.Companion.seconds class VisitorListener { @@ -71,13 +72,14 @@ class VisitorListener { if (!GardenAPI.inGarden()) return val visitorsInTab = VisitorAPI.visitorsInTabList(event.tabList) - VisitorAPI.getVisitors().forEach { - val name = it.visitorName - val time = System.currentTimeMillis() - LorenzUtils.lastWorldSwitch - val removed = name !in visitorsInTab && time > 2_000 - if (removed) { - logger.log("Removed old visitor: '$name'") - VisitorAPI.removeVisitor(name) + if (LorenzUtils.lastWorldSwitch.passedSince() > 2.seconds) { + VisitorAPI.getVisitors().forEach { + val name = it.visitorName + val removed = name !in visitorsInTab + if (removed) { + logger.log("Removed old visitor: '$name'") + VisitorAPI.removeVisitor(name) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt index 4d4b59b6f..e4d8e31a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt @@ -47,7 +47,6 @@ class MiningEventTracker { private val defaultCooldown = 1.minutes - private var lastWorldSwitch = SimpleTimeMark.farPast() private var eventEndTime = SimpleTimeMark.farPast() private var lastSentEvent: MiningEventType? = null @@ -55,7 +54,6 @@ class MiningEventTracker { @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { - lastWorldSwitch = SimpleTimeMark.farPast() eventEndTime = SimpleTimeMark.farPast() lastSentEvent = null } @@ -63,7 +61,7 @@ class MiningEventTracker { @SubscribeEvent fun onBossbarChange(event: BossbarUpdateEvent) { if (!LorenzUtils.inAdvancedMiningIsland()) return - if (lastWorldSwitch.passedSince() < 5.seconds) return + if (LorenzUtils.lastWorldSwitch.passedSince() < 5.seconds) return if (!eventEndTime.isInPast()) { return } |