From 12adb9a9658d273e97f2e2afafe0f454a5f147cb Mon Sep 17 00:00:00 2001 From: LeoDog896 Date: Fri, 15 Jan 2021 13:05:21 -0500 Subject: [PATCH] *Actually important Microoptimization* Anything that handles every single connected player should be optimized --- src/main/java/net/minestom/server/MinecraftServer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/MinecraftServer.java b/src/main/java/net/minestom/server/MinecraftServer.java index 4c63b7535..ab0bf5ded 100644 --- a/src/main/java/net/minestom/server/MinecraftServer.java +++ b/src/main/java/net/minestom/server/MinecraftServer.java @@ -476,9 +476,7 @@ public final class MinecraftServer { MinecraftServer.chunkViewDistance = chunkViewDistance; if (started) { - final Collection players = connectionManager.getOnlinePlayers(); - - players.forEach(player -> { + for (final Player player : connectionManager.getOnlinePlayers()) { final Chunk playerChunk = player.getChunk(); if (playerChunk != null) { @@ -512,12 +510,12 @@ public final class MinecraftServer { "The entity view distance must be between 0 and 32"); MinecraftServer.entityViewDistance = entityViewDistance; if (started) { - connectionManager.getOnlinePlayers().forEach(player -> { + for (final Player player : connectionManager.getOnlinePlayers()) { final Chunk playerChunk = player.getChunk(); if (playerChunk != null) { player.refreshVisibleEntities(playerChunk); } - }); + } } }