mirror of
https://github.com/timvisee/lazymc.git
synced 2025-05-19 04:40:22 -07:00
Server should never sleep if players are connected
This commit is contained in:
parent
b1dd8da7c6
commit
62422f2ef0
@ -162,6 +162,18 @@ impl ServerState {
|
|||||||
return false;
|
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
|
// Last active time must have passed sleep threshold
|
||||||
if let Some(last_idle) = self.last_active.lock().unwrap().as_ref() {
|
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);
|
return last_idle.elapsed() >= Duration::from_secs(config.time.sleep_after as u64);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user