diff options
author | embeddedt <42941056+embeddedt@users.noreply.github.com> | 2022-12-26 18:58:46 -0500 |
---|---|---|
committer | embeddedt <42941056+embeddedt@users.noreply.github.com> | 2022-12-26 18:58:46 -0500 |
commit | 1075665def4a41cf0064255a6da1d1a652f5d473 (patch) | |
tree | 11bba64e8f28ce8b83adc05252b75f17e2ccbf6a /spark-sponge8/src/main | |
parent | d9550259c1995d21fc345c58f2e531fdecf75acd (diff) | |
parent | d9655c40c02aef137c7a6a00a1cc90a1e6fb08d1 (diff) | |
download | spark-1075665def4a41cf0064255a6da1d1a652f5d473.tar.gz spark-1075665def4a41cf0064255a6da1d1a652f5d473.tar.bz2 spark-1075665def4a41cf0064255a6da1d1a652f5d473.zip |
Merge remote-tracking branch 'lucko/master' into forge-1.7.10
Diffstat (limited to 'spark-sponge8/src/main')
3 files changed, 36 insertions, 4 deletions
diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java index fa4ac45..7f02e75 100644 --- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java +++ b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8ClassSourceLookup.java @@ -22,7 +22,7 @@ package me.lucko.spark.sponge; import com.google.common.collect.ImmutableMap; -import me.lucko.spark.common.util.ClassSourceLookup; +import me.lucko.spark.common.sampler.source.ClassSourceLookup; import org.spongepowered.api.Game; import org.spongepowered.plugin.PluginCandidate; diff --git a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java index 83b2ec2..b1d31e9 100644 --- a/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java +++ b/spark-sponge8/src/main/java/me/lucko/spark/sponge/Sponge8SparkPlugin.java @@ -30,8 +30,9 @@ import me.lucko.spark.common.monitor.ping.PlayerPingProvider; import me.lucko.spark.common.platform.PlatformInfo; import me.lucko.spark.common.platform.world.WorldInfoProvider; import me.lucko.spark.common.sampler.ThreadDumper; +import me.lucko.spark.common.sampler.source.ClassSourceLookup; +import me.lucko.spark.common.sampler.source.SourceMetadata; import me.lucko.spark.common.tick.TickHook; -import me.lucko.spark.common.util.ClassSourceLookup; import net.kyori.adventure.text.Component; @@ -52,8 +53,10 @@ import org.spongepowered.api.event.lifecycle.StartedEngineEvent; import org.spongepowered.api.event.lifecycle.StoppingEngineEvent; import org.spongepowered.plugin.PluginContainer; import org.spongepowered.plugin.builtin.jvm.Plugin; +import org.spongepowered.plugin.metadata.model.PluginContributor; import java.nio.file.Path; +import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutorService; @@ -178,6 +181,18 @@ public class Sponge8SparkPlugin implements SparkPlugin { } @Override + public Collection<SourceMetadata> getKnownSources() { + return SourceMetadata.gather( + this.game.pluginManager().plugins(), + plugin -> plugin.metadata().id(), + plugin -> plugin.metadata().version().toString(), + plugin -> plugin.metadata().contributors().stream() + .map(PluginContributor::name) + .collect(Collectors.joining(", ")) + ); + } + + @Override public PlayerPingProvider createPlayerPingProvider() { if (this.game.isServerAvailable()) { return new Sponge8PlayerPingProvider(this.game.server()); 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()); |