public function checkSleep()
{
if (count($this->players) === 0) {
return;
}
$resetTime = true;
foreach ($this->getPlayers() as $p) {
if (!$p->isSleeping()) {
$resetTime = false;
break;
}
}
if ($resetTime) {
$time = $this->getTime() % Level::TIME_FULL;
if ($time >= Level::TIME_NIGHT and $time < Level::TIME_SUNRISE) {
$this->setTime($this->getTime() + Level::TIME_FULL - $time);
foreach ($this->getPlayers() as $p) {
$p->stopSleep();
}
}
}
}