Server should never sleep if players are connected

This commit is contained in:
timvisee 2021-11-08 20:27:57 +01:00
parent b1dd8da7c6
commit 62422f2ef0
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172

View File

@ -162,6 +162,18 @@ impl ServerState {
return false;
}
// Never idle if players are online
let players_online = self
.status
.lock()
.unwrap()
.as_ref()
.map(|status| status.players.online > 0)
.unwrap_or(false);
if players_online {
return false;
}
// Last active time must have passed sleep threshold
if let Some(last_idle) = self.last_active.lock().unwrap().as_ref() {
return last_idle.elapsed() >= Duration::from_secs(config.time.sleep_after as u64);