Skip to content

Commit

Permalink
Fix: Last Server Chat Spam (hannibal002#2495)
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Sep 10, 2024
1 parent d6c9b63 commit f75c993
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class LastServersConfig {

@Expose
@ConfigOption(name = "Enabled", desc = "Receive notifications when you rejoin a server you have previously joined.")
@ConfigOption(name = "Enabled", desc = "Receive notifications when you rejoin a server you were in previously.")
@ConfigEditorBoolean
@FeatureToggle
public boolean enabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ object LastServers {
// 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()
if (lastServerId == id) {
lastServers[id] = SimpleTimeMark.now()
return
}

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.chat("§7You were already on this server §b${it.format()}§7 ago.")
}
ChatUtils.debug("Adding $id to last servers.")
lastServerId = id
lastServers[id] = SimpleTimeMark.now()
}

private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
Expand Down

0 comments on commit f75c993

Please sign in to comment.