blob: 580cdaf078975ad9ea981edfad9aaeaed87a9485 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
--- 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<ServerPlayer> list) {
- int j = (int) list.stream().filter(Player::isSleepingLongEnough).count();
+ public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List<ServerPlayer> 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
}
}
|