From 94247cdcad6c43a9163d6f66dcd6b90139a81dc7 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 8 Aug 2018 11:02:28 +0300 Subject: [PATCH] Reduced performance impact of BukkitTPSCountTimer #639 --- .../system/tasks/server/BukkitTPSCountTimer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java index 421d4b8d9..ebd4c3bfb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/server/BukkitTPSCountTimer.java @@ -5,6 +5,7 @@ import com.djrapitops.plan.data.container.TPS; import com.djrapitops.plan.system.tasks.TPSCountTimer; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.utility.log.Log; +import org.bukkit.World; import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; @@ -107,7 +108,11 @@ public class BukkitTPSCountTimer extends TPSCountTimer { * @return amount of loaded chunks */ private int getLoadedChunks() { - return plugin.getServer().getWorlds().stream().mapToInt(world -> world.getLoadedChunks().length).sum(); + int sum = 0; + for (World world : plugin.getServer().getWorlds()) { + sum += world.getLoadedChunks().length; + } + return sum; } /** @@ -116,6 +121,10 @@ public class BukkitTPSCountTimer extends TPSCountTimer { * @return amount of entities */ protected int getEntityCount() { - return plugin.getServer().getWorlds().stream().mapToInt(world -> world.getEntities().size()).sum(); + int sum = 0; + for (World world : plugin.getServer().getWorlds()) { + sum += world.getEntityCount(); + } + return sum; } }