9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-archived-patches/unapplied/server/minecraft-patches/features/0058-Remove-stream-and-double-iteration-in-enough-deep-sl.patch
Dreeam 236010caba Cooking Tutorial
1. Wet the drys
2. Dry the wets
3. Wet the drys
4. Dry the wets
5. Wet the drys
6. Now dust the wets
2025-03-28 03:11:27 -04:00

40 lines
2.0 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/net/minecraft/server/players/SleepStatus.java b/net/minecraft/server/players/SleepStatus.java
index 3a3e6992563236141db687084aeec9684437a7db..e6827e90b685f88d945010f2c8c5aead52b0856e 100644
--- a/net/minecraft/server/players/SleepStatus.java
+++ b/net/minecraft/server/players/SleepStatus.java
@@ -15,9 +15,24 @@ public class SleepStatus {
public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List<ServerPlayer> sleepingPlayers) {
// CraftBukkit start
- int i = (int) sleepingPlayers.stream().filter(player -> player.isSleepingLongEnough() || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())).count(); // Purpur - AFK API
- boolean anyDeepSleep = sleepingPlayers.stream().anyMatch(Player::isSleepingLongEnough);
- return anyDeepSleep && i >= this.sleepersNeeded(requiredSleepPercentage);
+ // Leaf start - Remove stream and double iteration in enough deep sleeping player check
+ int count = 0;
+ boolean anyPlayerSleeping = false;
+
+ for (ServerPlayer player : sleepingPlayers) {
+ final boolean isSleepingLongEnough = player.isSleepingLongEnough();
+
+ if (isSleepingLongEnough) {
+ anyPlayerSleeping = true;
+ }
+
+ if (isSleepingLongEnough || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())) { // Purpur - AFK API
+ count++;
+ }
+ }
+
+ return anyPlayerSleeping && count >= this.sleepersNeeded(requiredSleepPercentage);
+ // Leaf end - Remove stream and double iteration in enough deep sleeping player check
// CraftBukkit end
}