--- a/net/minecraft/server/players/SleepStatus.java +++ b/net/minecraft/server/players/SleepStatus.java @@ -18,9 +18,12 @@ } public boolean areEnoughDeepSleeping(int percentage, List players) { - int j = (int) players.stream().filter(Player::isSleepingLongEnough).count(); + // CraftBukkit start + int j = (int) players.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping; }).count(); + boolean anyDeepSleep = players.stream().anyMatch(Player::isSleepingLongEnough); - return j >= this.sleepersNeeded(percentage); + return anyDeepSleep && j >= this.sleepersNeeded(percentage); + // CraftBukkit end } public int sleepersNeeded(int percentage) { @@ -42,18 +45,24 @@ this.activePlayers = 0; this.sleepingPlayers = 0; Iterator iterator = players.iterator(); + boolean anySleep = false; // CraftBukkit while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); if (!entityplayer.isSpectator()) { ++this.activePlayers; - if (entityplayer.isSleeping()) { + if (entityplayer.isSleeping() || entityplayer.fauxSleeping) { // CraftBukkit ++this.sleepingPlayers; } + // CraftBukkit start + if (entityplayer.isSleeping()) { + anySleep = true; + } + // CraftBukkit end } } - return (j > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || j != this.sleepingPlayers); + return anySleep && (j > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || j != this.sleepingPlayers); // CraftBukkit } }