aboutsummaryrefslogtreecommitdiff
path: root/spark-sponge8
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2022-11-26 23:00:53 +0000
committerLuck <git@lucko.me>2022-11-26 23:01:02 +0000
commit65f9460a1a27e930b3749525766fd44d57b65300 (patch)
tree8ddf02527b465bd63b768b5ca0c8ee448f272c67 /spark-sponge8
parentdc52696138b2506b5a36e967b98af7e3f67ab0b0 (diff)
downloadspark-65f9460a1a27e930b3749525766fd44d57b65300.tar.gz
spark-65f9460a1a27e930b3749525766fd44d57b65300.tar.bz2
spark-65f9460a1a27e930b3749525766fd44d57b65300.zip
Include player/entity/chunk counts in window statistics
Diffstat (limited to 'spark-sponge8')
-rw-r--r--spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java
index bff4d6e..69b4515 100644
--- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.java
+++ b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8WorldInfoProvider.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;
@@ -45,8 +46,24 @@ public class Sponge8WorldInfoProvider implements WorldInfoProvider {
}
@Override
- public Result<Sponge7ChunkInfo> poll() {
- Result<Sponge7ChunkInfo> data = new Result<>();
+ public CountsResult pollCounts() {
+ int players = this.server.onlinePlayers().size();
+ int entities = 0;
+ int tileEntities = 0;
+ int chunks = 0;
+
+ for (ServerWorld world : this.server.worldManager().worlds()) {
+ entities += world.entities().size();
+ tileEntities += world.blockEntities().size();
+ chunks += Iterables.size(world.loadedChunks());
+ }
+
+ return new CountsResult(players, entities, tileEntities, chunks);
+ }
+
+ @Override
+ public ChunksResult<Sponge7ChunkInfo> pollChunks() {
+ ChunksResult<Sponge7ChunkInfo> data = new ChunksResult<>();
for (ServerWorld world : this.server.worldManager().worlds()) {
List<WorldChunk> chunks = Lists.newArrayList(world.loadedChunks());