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/forge/ForgePlatformInfo.java | 54 ++++++++++++++++++++++ .../spark/forge/plugin/ForgeClientSparkPlugin.java | 11 +++-- .../spark/forge/plugin/ForgeServerSparkPlugin.java | 11 +++-- .../lucko/spark/forge/plugin/ForgeSparkPlugin.java | 1 + 4 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java (limited to 'spark-forge/src/main/java') diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java new file mode 100644 index 0000000..0544072 --- /dev/null +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java @@ -0,0 +1,54 @@ +/* + * 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.forge; + +import me.lucko.spark.common.PlatformInfo; +import net.minecraftforge.versions.forge.ForgeVersion; +import net.minecraftforge.versions.mcp.MCPVersion; + +public class ForgePlatformInfo implements PlatformInfo { + + private final Type type; + + public ForgePlatformInfo(Type type) { + this.type = type; + } + + @Override + public Type getType() { + return type; + } + + @Override + public String getName() { + return "Forge"; + } + + @Override + public String getVersion() { + return ForgeVersion.getVersion(); + } + + @Override + public String getMinecraftVersion() { + return MCPVersion.getMCVersion(); + } +} diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java index 070c28a..278e838 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java @@ -27,12 +27,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import me.lucko.spark.common.PlatformInfo; import me.lucko.spark.common.sampler.tick.TickHook; import me.lucko.spark.common.sampler.tick.TickReporter; -import me.lucko.spark.forge.ForgeCommandSender; -import me.lucko.spark.forge.ForgeSparkMod; -import me.lucko.spark.forge.ForgeTickHook; -import me.lucko.spark.forge.ForgeTickReporter; +import me.lucko.spark.forge.*; import net.minecraft.client.Minecraft; import net.minecraft.client.network.play.ClientPlayNetHandler; import net.minecraft.command.ICommandSource; @@ -143,6 +141,11 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin implements Suggesti return new ForgeTickReporter(TickEvent.Type.CLIENT); } + @Override + public PlatformInfo getPlatformInfo() { + return new ForgePlatformInfo(PlatformInfo.Type.CLIENT); + } + @Override public String getCommandName() { return "sparkc"; diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java index 4051d24..c433c95 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java @@ -27,12 +27,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.SuggestionProvider; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import me.lucko.spark.common.PlatformInfo; import me.lucko.spark.common.sampler.tick.TickHook; import me.lucko.spark.common.sampler.tick.TickReporter; -import me.lucko.spark.forge.ForgeCommandSender; -import me.lucko.spark.forge.ForgeSparkMod; -import me.lucko.spark.forge.ForgeTickHook; -import me.lucko.spark.forge.ForgeTickReporter; +import me.lucko.spark.forge.*; import net.minecraft.command.CommandSource; import net.minecraft.command.ICommandSource; import net.minecraft.entity.player.PlayerEntity; @@ -126,6 +124,11 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command< return new ForgeTickReporter(TickEvent.Type.SERVER); } + @Override + public PlatformInfo getPlatformInfo() { + return new ForgePlatformInfo(PlatformInfo.Type.SERVER); + } + @Override public String getCommandName() { return "spark"; diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java index 0f0ce11..920ca24 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeSparkPlugin.java @@ -93,4 +93,5 @@ public abstract class ForgeSparkPlugin implements SparkPlugin { public ThreadDumper getDefaultThreadDumper() { return new ThreadDumper.Specific(new long[]{Thread.currentThread().getId()}); } + } -- cgit