9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 00:49:31 +00:00
Files
Leaf/patches/server/0110-Remove-stream-and-double-iteration-in-enough-deep-sl.patch
Dreeam f56dc061d3 Updated Upstream (Paper/Gale)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@755a775 [ci skip] rebuild patches
PaperMC/Paper@3b9db2b Updated Upstream (Bukkit/CraftBukkit) (#11501)
PaperMC/Paper@c13f9fd Fix potential annotation testing interruption (#11460)
PaperMC/Paper@260c3bb Always send Banner patterns to the client (#11506)
PaperMC/Paper@14a48cd Some small touchups to the GUI (#11505)
PaperMC/Paper@d348cb8 Restrict BlockProjectileSource#launchProjectile

Gale Changes:
Dreeam-qwq/Gale@e893e3d Updated Upstream (Paper)
2024-10-22 22:05:12 -04:00

40 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 17 Oct 2024 01:51:38 -0400
Subject: [PATCH] Remove stream and double iteration in enough deep sleeping
player check
diff --git a/src/main/java/net/minecraft/server/players/SleepStatus.java b/src/main/java/net/minecraft/server/players/SleepStatus.java
index caa8a69bde0c212c36dd990a67836ac2f95548c0..5ae435dcc078a5b9af90f01fa70f1a9d6f34e2be 100644
--- a/src/main/java/net/minecraft/server/players/SleepStatus.java
+++ b/src/main/java/net/minecraft/server/players/SleepStatus.java
@@ -19,10 +19,24 @@ public class SleepStatus {
public boolean areEnoughDeepSleeping(int percentage, List<ServerPlayer> players) {
// CraftBukkit start
- int j = (int) players.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping || (eh.level().purpurConfig.idleTimeoutCountAsSleeping && eh.isAfk()); }).count(); // Purpur
- boolean anyDeepSleep = players.stream().anyMatch(Player::isSleepingLongEnough);
+ // Leaf start - Remove stream and double iteration in enough deep sleeping player check
+ int count = 0;
+ boolean anyPlayerSleeping = false;
- return anyDeepSleep && j >= this.sleepersNeeded(percentage);
+ for (ServerPlayer player : players) {
+ final boolean isSleepingLongEnough = player.isSleepingLongEnough();
+
+ if (isSleepingLongEnough) {
+ anyPlayerSleeping = true;
+ }
+
+ if (isSleepingLongEnough || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())) { // Purpur
+ count++;
+ }
+ }
+
+ return anyPlayerSleeping && count >= this.sleepersNeeded(percentage);
+ // Leaf end - Remove stream and double iteration in enough deep sleeping player check
// CraftBukkit end
}