diff options
author | Luck <git@lucko.me> | 2022-11-26 23:00:53 +0000 |
---|---|---|
committer | Luck <git@lucko.me> | 2022-11-26 23:01:02 +0000 |
commit | 65f9460a1a27e930b3749525766fd44d57b65300 (patch) | |
tree | 8ddf02527b465bd63b768b5ca0c8ee448f272c67 /spark-sponge7/src/main/java/me/lucko/spark | |
parent | dc52696138b2506b5a36e967b98af7e3f67ab0b0 (diff) | |
download | spark-65f9460a1a27e930b3749525766fd44d57b65300.tar.gz spark-65f9460a1a27e930b3749525766fd44d57b65300.tar.bz2 spark-65f9460a1a27e930b3749525766fd44d57b65300.zip |
Include player/entity/chunk counts in window statistics
Diffstat (limited to 'spark-sponge7/src/main/java/me/lucko/spark')
-rw-r--r-- | spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java index fa6fa6b..df58028 100644 --- a/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java +++ b/spark-sponge7/src/main/java/me/lucko/spark/sponge/Sponge7WorldInfoProvider.java @@ -20,6 +20,7 @@ package me.lucko.spark.sponge; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import me.lucko.spark.common.platform.world.AbstractChunkInfo; @@ -44,8 +45,24 @@ public class Sponge7WorldInfoProvider implements WorldInfoProvider { } @Override - public Result<Sponge7ChunkInfo> poll() { - Result<Sponge7ChunkInfo> data = new Result<>(); + public CountsResult pollCounts() { + int players = this.server.getOnlinePlayers().size(); + int entities = 0; + int tileEntities = 0; + int chunks = 0; + + for (World world : this.server.getWorlds()) { + entities += world.getEntities().size(); + tileEntities += world.getTileEntities().size(); + chunks += Iterables.size(world.getLoadedChunks()); + } + + return new CountsResult(players, entities, tileEntities, chunks); + } + + @Override + public ChunksResult<Sponge7ChunkInfo> pollChunks() { + ChunksResult<Sponge7ChunkInfo> data = new ChunksResult<>(); for (World world : this.server.getWorlds()) { List<Chunk> chunks = Lists.newArrayList(world.getLoadedChunks()); |