From bcea61e5b221fd0c0ee6c2bc17c53473dc54c4fd Mon Sep 17 00:00:00 2001 From: vaperion Date: Sat, 31 Dec 2022 15:58:43 +0100 Subject: Exclude null chunks from the total chunk count --- .../java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'spark-bukkit/src') diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java index 8a4c0e4..babb0bc 100644 --- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java +++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java @@ -70,12 +70,21 @@ public class BukkitWorldInfoProvider implements WorldInfoProvider { chunks += world.getChunkCount(); } else { entities += world.getEntities().size(); + Chunk[] chunksArray = world.getLoadedChunks(); + int nullChunks = 0; + for (Chunk chunk : chunksArray) { + if (chunk == null) { + ++nullChunks; + continue; + } + BlockState[] tileEntitiesArray = chunk.getTileEntities(); tileEntities += tileEntitiesArray != null ? tileEntitiesArray.length : 0; } - chunks += chunksArray.length; + + chunks += chunksArray.length - nullChunks; } } -- cgit