diff options
author | embeddedt <42941056+embeddedt@users.noreply.github.com> | 2023-05-24 11:05:06 -0400 |
---|---|---|
committer | embeddedt <42941056+embeddedt@users.noreply.github.com> | 2023-05-24 11:05:06 -0400 |
commit | 67c1d7ba2f63cda64ea54e9630238e2b3a963a17 (patch) | |
tree | 55c404f59b27951299971a1f90a95ad0faba8ee9 /spark-bukkit/src | |
parent | a73c5d41be8eb3f25bfbd2bf9908ba4c8ca027b7 (diff) | |
parent | f5b35cf7590e5e0d3f5b604216e1ba4a3d641c9d (diff) | |
download | spark-67c1d7ba2f63cda64ea54e9630238e2b3a963a17.tar.gz spark-67c1d7ba2f63cda64ea54e9630238e2b3a963a17.tar.bz2 spark-67c1d7ba2f63cda64ea54e9630238e2b3a963a17.zip |
Merge remote-tracking branch 'lucko/master' into forge-1.7.10
Diffstat (limited to 'spark-bukkit/src')
-rw-r--r-- | spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitWorldInfoProvider.java | 15 |
1 files changed, 13 insertions, 2 deletions
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 8f876cf..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 @@ -27,6 +27,7 @@ import me.lucko.spark.common.platform.world.WorldInfoProvider; import org.bukkit.Chunk; import org.bukkit.Server; import org.bukkit.World; +import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -69,11 +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) { - tileEntities += chunk.getTileEntities().length; + if (chunk == null) { + ++nullChunks; + continue; + } + + BlockState[] tileEntitiesArray = chunk.getTileEntities(); + tileEntities += tileEntitiesArray != null ? tileEntitiesArray.length : 0; } - chunks += chunksArray.length; + + chunks += chunksArray.length - nullChunks; } } |