mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 10:44:39 +01:00
30e4583dbe
By: Initial Source <noreply+automated@papermc.io>
44 lines
1.8 KiB
Diff
44 lines
1.8 KiB
Diff
--- a/net/minecraft/server/players/SleepStatus.java
|
|
+++ b/net/minecraft/server/players/SleepStatus.java
|
|
@@ -18,9 +18,12 @@
|
|
}
|
|
|
|
public boolean areEnoughDeepSleeping(int percentage, List<ServerPlayer> 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
|
|
}
|
|
}
|