blob: ff7a4138c070d5be42824b86b2bc0ca0ee2abe0a (
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
49
|
--- a/net/minecraft/server/players/SleepStatus.java
+++ b/net/minecraft/server/players/SleepStatus.java
@@ -14,8 +18,12 @@
}
public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List<ServerPlayer> sleepingPlayers) {
- int i = (int)sleepingPlayers.stream().filter(Player::isSleepingLongEnough).count();
- return i >= this.sleepersNeeded(requiredSleepPercentage);
+ // CraftBukkit start
+ int j = (int) sleepingPlayers.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping; }).count();
+ boolean anyDeepSleep = sleepingPlayers.stream().anyMatch(Player::isSleepingLongEnough);
+
+ return anyDeepSleep && j >= this.sleepersNeeded(requiredSleepPercentage);
+ // CraftBukkit end
}
public int sleepersNeeded(int requiredSleepPercentage) {
@@ -35,16 +44,25 @@
int i1 = this.sleepingPlayers;
this.activePlayers = 0;
this.sleepingPlayers = 0;
+ Iterator iterator = players.iterator();
+ boolean anySleep = false; // CraftBukkit
- for (ServerPlayer serverPlayer : players) {
- if (!serverPlayer.isSpectator()) {
- this.activePlayers++;
- if (serverPlayer.isSleeping()) {
- this.sleepingPlayers++;
+ while (iterator.hasNext()) {
+ ServerPlayer entityplayer = (ServerPlayer) iterator.next();
+
+ if (!entityplayer.isSpectator()) {
+ ++this.activePlayers;
+ if (entityplayer.isSleeping() || entityplayer.fauxSleeping) { // CraftBukkit
+ ++this.sleepingPlayers;
}
+ // CraftBukkit start
+ if (entityplayer.isSleeping()) {
+ anySleep = true;
+ }
+ // CraftBukkit end
}
}
- return (i1 > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || i1 != this.sleepingPlayers);
+ return anySleep && (j > 0 || this.sleepingPlayers > 0) && (i != this.activePlayers || j != this.sleepingPlayers); // CraftBukkit
}
}
|