aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-09-10 20:10:00 +0200
committerGitHub <noreply@github.com>2024-09-10 20:10:00 +0200
commita8abfbb456ba4e4cc846897b4eaac7b35deb32e4 (patch)
treece868298aa57eeb42bb152e57621d6a3f0d11c5a /src/main
parentf8a3b96bb34db1105d0f0d92b77ee38095c45792 (diff)
downloadskyhanni-a8abfbb456ba4e4cc846897b4eaac7b35deb32e4.tar.gz
skyhanni-a8abfbb456ba4e4cc846897b4eaac7b35deb32e4.tar.bz2
skyhanni-a8abfbb456ba4e4cc846897b4eaac7b35deb32e4.zip
Improvement: Last Server (#2494)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/LastServers.kt8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LastServers.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LastServers.kt
index 8a4023314..8bc2d96e4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/LastServers.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LastServers.kt
@@ -20,15 +20,19 @@ object LastServers {
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
- if (!isEnabled() || HypixelData.serverId == lastServerId) return
+ if (!isEnabled()) return
val id = HypixelData.serverId ?: return
+ // Update the time of the current server if the player is still on the same server.
+ // This is necessary because the player can be on the same server for a long time.
+ // And if the player leaves the server and joins it again, it still warns the player.
+ lastServers[id] = SimpleTimeMark.now()
+
lastServers.entries.removeIf { it.value.passedSince() > config.warnTime.seconds }
lastServers[id]?.passedSince()?.let {
ChatUtils.chat("§7You already joined this server §b${it.format()}§7 ago.")
}
ChatUtils.debug("Adding $id to last servers.")
- lastServers[id] = SimpleTimeMark.now()
lastServerId = id
}