--- a/net/minecraft/server/players/SleepStatus.java +++ b/net/minecraft/server/players/SleepStatus.java @@ -17,10 +17,13 @@ return this.sleepingPlayers >= this.sleepersNeeded(i); } - public boolean areEnoughDeepSleeping(int i, List list) { - int j = (int) list.stream().filter(Player::isSleepingLongEnough).count(); + public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List sleepingPlayers) { + // CraftBukkit start + int j = (int) sleepingPlayers.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping; }).count(); + boolean anyDeepSleep = sleepingPlayers.stream().anyMatch(Player::isSleepingLongEnough); - return j >= this.sleepersNeeded(i); + return anyDeepSleep && j >= this.sleepersNeeded(requiredSleepPercentage); + // CraftBukkit end } public int sleepersNeeded(int i) { @@ -41,19 +44,25 @@ this.activePlayers = 0; this.sleepingPlayers = 0; - Iterator iterator = list.iterator(); + Iterator iterator = players.iterator(); + boolean anySleep = false; // CraftBukkit while (iterator.hasNext()) { ServerPlayer serverplayer = (ServerPlayer) iterator.next(); if (!serverplayer.isSpectator()) { ++this.activePlayers; - if (serverplayer.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 } }