mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
SPIGOT-6542: Fix counting players with fauxSleeping = true
By: Ivan R <namelessftw1206@hotmail.com>
This commit is contained in:
parent
e4f5bec8b3
commit
c751b9c098
1 changed files with 31 additions and 7 deletions
|
@ -1,20 +1,44 @@
|
|||
--- a/net/minecraft/server/players/SleepStatus.java
|
||||
+++ b/net/minecraft/server/players/SleepStatus.java
|
||||
@@ -18,7 +18,7 @@
|
||||
@@ -18,9 +18,12 @@
|
||||
}
|
||||
|
||||
public boolean a(int i, List<EntityPlayer> list) {
|
||||
- int j = (int) list.stream().filter(EntityHuman::isDeeplySleeping).count();
|
||||
+ int j = (int) list.stream().filter((eh) -> { return eh.isDeeplySleeping() || eh.fauxSleeping; }).count(); // CraftBukkit
|
||||
+ // CraftBukkit start
|
||||
+ int j = (int) list.stream().filter((eh) -> { return eh.isDeeplySleeping() || eh.fauxSleeping; }).count();
|
||||
+ boolean anyDeepSleep = list.stream().anyMatch(EntityHuman::isDeeplySleeping);
|
||||
|
||||
return j >= this.b(i);
|
||||
- return j >= this.b(i);
|
||||
+ return anyDeepSleep && j >= this.b(i);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
public int b(int i) {
|
||||
@@ -42,18 +45,24 @@
|
||||
this.activePlayers = 0;
|
||||
this.sleepingPlayers = 0;
|
||||
Iterator iterator = list.iterator();
|
||||
+ boolean anySleep = false; // CraftBukkit
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
- if (!entityplayer.isSpectator()) {
|
||||
+ if (!entityplayer.isSpectator() && !entityplayer.fauxSleeping) { // CraftBukkit
|
||||
if (!entityplayer.isSpectator()) {
|
||||
++this.activePlayers;
|
||||
if (entityplayer.isSleeping()) {
|
||||
- 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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue