From a2af3f8f7e3693f3e445d2998938bf448d47c35f Mon Sep 17 00:00:00 2001 From: MD <1917406+md678685@users.noreply.github.com> Date: Tue, 23 Jun 2020 12:02:43 +0100 Subject: Include platform info in sampler and heap summary data (#58) --- .../me/lucko/spark/sponge/SpongePlatformInfo.java | 47 ++++++++++++++++++++++ .../me/lucko/spark/sponge/SpongeSparkPlugin.java | 6 +++ 2 files changed, 53 insertions(+) create mode 100644 spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java (limited to 'spark-sponge/src') diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java new file mode 100644 index 0000000..be0e09d --- /dev/null +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java @@ -0,0 +1,47 @@ +/* + * This file is part of spark. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package me.lucko.spark.sponge; + +import me.lucko.spark.common.PlatformInfo; +import org.spongepowered.api.Platform; +import org.spongepowered.api.Sponge; + +public class SpongePlatformInfo implements PlatformInfo { + @Override + public Type getType() { + return Type.SERVER; + } + + @Override + public String getName() { + return "Sponge"; + } + + @Override + public String getVersion() { + return Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getVersion().orElse("unknown"); + } + + @Override + public String getMinecraftVersion() { + return Sponge.getPlatform().getMinecraftVersion().getName(); + } +} diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java index ae0efef..0c61b0f 100644 --- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java @@ -23,6 +23,7 @@ package me.lucko.spark.sponge; import com.google.inject.Inject; import me.lucko.spark.common.SparkPlatform; import me.lucko.spark.common.SparkPlugin; +import me.lucko.spark.common.PlatformInfo; import me.lucko.spark.common.sampler.ThreadDumper; import me.lucko.spark.common.sampler.tick.TickHook; import org.spongepowered.api.Game; @@ -124,6 +125,11 @@ public class SpongeSparkPlugin implements SparkPlugin { return new SpongeTickHook(this); } + @Override + public PlatformInfo getPlatformInfo() { + return new SpongePlatformInfo(); + } + private static final class SparkCommand implements CommandCallable { private final SpongeSparkPlugin plugin; -- cgit