aboutsummaryrefslogtreecommitdiff
path: root/spark-sponge/src
diff options
context:
space:
mode:
authorMD <1917406+md678685@users.noreply.github.com>2020-06-23 12:02:43 +0100
committerGitHub <noreply@github.com>2020-06-23 12:02:43 +0100
commita2af3f8f7e3693f3e445d2998938bf448d47c35f (patch)
tree91f2f058fb114e96f121b9ee31a69dacb2f4e67f /spark-sponge/src
parent12918d40b17a15f0432f7ad85d8db60a87e7c5b8 (diff)
downloadspark-a2af3f8f7e3693f3e445d2998938bf448d47c35f.tar.gz
spark-a2af3f8f7e3693f3e445d2998938bf448d47c35f.tar.bz2
spark-a2af3f8f7e3693f3e445d2998938bf448d47c35f.zip
Include platform info in sampler and heap summary data (#58)
Diffstat (limited to 'spark-sponge/src')
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java47
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java6
2 files changed, 53 insertions, 0 deletions
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) <luck@lucko.me>
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+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;