Skip to content

Commit

Permalink
Fix online players list (#5)
Browse files Browse the repository at this point in the history
* Add missing new players after quarantine period
  • Loading branch information
imedvedko authored Oct 15, 2019
1 parent a39285e commit 24c465b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.logging.Level
import java.util.logging.Logger


class NotificationEventListener(private val joinedMessage: String,
private val leftMessage: String,
private val onlineMessage: String,
Expand Down Expand Up @@ -55,10 +54,13 @@ class NotificationEventListener(private val joinedMessage: String,
private fun Player.leftNotification() {
val quarantineId = UUID.randomUUID()
quarantine[name] = quarantineId
onlinePlayers().filter { this != it }.filter(authMeApi::isAuthenticated).map(Player::getName).let {
onlinePlayers().filter { this != it }.filter(authMeApi::isAuthenticated).let { onlinePlayers ->
quarantineScheduler.invoke {
if (quarantine.remove(name, quarantineId)) {
notification(leftMessage, it)
onlinePlayers.plus(onlinePlayers().filter(authMeApi::isAuthenticated))
.map(Player::getName)
.distinct()
.let { onlinePlayers -> notification(leftMessage, onlinePlayers) }
}
}
}
Expand Down

0 comments on commit 24c465b

Please sign in to comment.