diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/players/SleepStatus.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/players/SleepStatus.java.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/players/SleepStatus.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/players/SleepStatus.java.patch new file mode 100644 index 0000000000..f0ac08abc2 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/players/SleepStatus.java.patch @@ -0,0 +1,69 @@ +--- a/net/minecraft/server/players/SleepStatus.java ++++ b/net/minecraft/server/players/SleepStatus.java +@@ -13,18 +13,21 @@ + + public SleepStatus() {} + +- public boolean areEnoughSleeping(int i) { +- return this.sleepingPlayers >= this.sleepersNeeded(i); ++ public boolean areEnoughSleeping(int requiredSleepPercentage) { ++ return this.sleepingPlayers >= this.sleepersNeeded(requiredSleepPercentage); + } + +- 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) { +- return Math.max(1, Mth.ceil((float) (this.activePlayers * i) / 100.0F)); ++ public int sleepersNeeded(int requiredSleepPercentage) { ++ return Math.max(1, Mth.ceil((float) (this.activePlayers * requiredSleepPercentage) / 100.0F)); + } + + public void removeAllSleepers() { +@@ -35,25 +38,31 @@ + return this.sleepingPlayers; + } + +- public boolean update(List<ServerPlayer> list) { ++ public boolean update(List<ServerPlayer> players) { + int i = this.activePlayers; + int j = this.sleepingPlayers; + + 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(); ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); + +- if (!serverplayer.isSpectator()) { ++ if (!entityplayer.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 + } + } |