PaperMC/paper-server/patches/sources/net/minecraft/server/players/SleepStatus.java.patch
CraftBukkit/Spigot 30e4583dbe Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
2024-12-11 22:26:55 +01:00

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
}
}