aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitPlatformInfo.java16
-rw-r--r--spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java4
-rw-r--r--spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordPlatformInfo.java12
-rw-r--r--spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java4
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java1
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDump.java7
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java2
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectionMonitor.java9
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/platform/AbstractPlatformInfo.java17
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/platform/PlatformInfo.java (renamed from spark-common/src/main/java/me/lucko/spark/common/PlatformInfo.java)91
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java2
-rw-r--r--spark-common/src/main/proto/spark/spark.proto9
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/FabricPlatformInfo.java5
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java8
-rw-r--r--spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java2
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java5
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeClientSparkPlugin.java8
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java8
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java16
-rw-r--r--spark-sponge/src/main/java/me/lucko/spark/sponge/SpongeSparkPlugin.java4
-rw-r--r--spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityPlatformInfo.java5
-rw-r--r--spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java2
22 files changed, 137 insertions, 100 deletions
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitPlatformInfo.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitPlatformInfo.java
index 0cf9288..84ed1bf 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitPlatformInfo.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitPlatformInfo.java
@@ -20,10 +20,16 @@
package me.lucko.spark.bukkit;
-import me.lucko.spark.common.PlatformInfo;
-import org.bukkit.Bukkit;
+import me.lucko.spark.common.platform.AbstractPlatformInfo;
+import org.bukkit.Server;
+
+public class BukkitPlatformInfo extends AbstractPlatformInfo {
+ private final Server server;
+
+ public BukkitPlatformInfo(Server server) {
+ this.server = server;
+ }
-public class BukkitPlatformInfo implements PlatformInfo {
@Override
public Type getType() {
return Type.SERVER;
@@ -36,11 +42,11 @@ public class BukkitPlatformInfo implements PlatformInfo {
@Override
public String getVersion() {
- return Bukkit.getVersion();
+ return this.server.getVersion();
}
@Override
public String getMinecraftVersion() {
- return Bukkit.getMinecraftVersion();
+ return this.server.getMinecraftVersion();
}
}
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java
index 2ef11db..7d749eb 100644
--- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java
+++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitSparkPlugin.java
@@ -24,7 +24,7 @@ import me.lucko.spark.bukkit.placeholder.SparkMVdWPlaceholders;
import me.lucko.spark.bukkit.placeholder.SparkPlaceholderApi;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.sampler.tick.TickHook;
import me.lucko.spark.common.sampler.tick.TickReporter;
@@ -151,7 +151,7 @@ public class BukkitSparkPlugin extends JavaPlugin implements SparkPlugin {
@Override
public PlatformInfo getPlatformInfo() {
- return new BukkitPlatformInfo();
+ return new BukkitPlatformInfo(getServer());
}
private static boolean classExists(String className) {
diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordPlatformInfo.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordPlatformInfo.java
index 91a64c4..67cb17c 100644
--- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordPlatformInfo.java
+++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordPlatformInfo.java
@@ -20,10 +20,16 @@
package me.lucko.spark.bungeecord;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.AbstractPlatformInfo;
import net.md_5.bungee.api.ProxyServer;
-public class BungeeCordPlatformInfo implements PlatformInfo {
+public class BungeeCordPlatformInfo extends AbstractPlatformInfo {
+ private final ProxyServer proxy;
+
+ public BungeeCordPlatformInfo(ProxyServer proxy) {
+ this.proxy = proxy;
+ }
+
@Override
public Type getType() {
return Type.PROXY;
@@ -36,7 +42,7 @@ public class BungeeCordPlatformInfo implements PlatformInfo {
@Override
public String getVersion() {
- return ProxyServer.getInstance().getVersion();
+ return this.proxy.getVersion();
}
@Override
diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java
index ca02c14..5a3ad23 100644
--- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java
+++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/BungeeCordSparkPlugin.java
@@ -22,7 +22,7 @@ package me.lucko.spark.bungeecord;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.PlatformInfo;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin;
@@ -77,7 +77,7 @@ public class BungeeCordSparkPlugin extends Plugin implements SparkPlugin {
@Override
public PlatformInfo getPlatformInfo() {
- return new BungeeCordPlatformInfo();
+ return new BungeeCordPlatformInfo(getProxy());
}
private static final class SparkCommand extends Command implements TabExecutor {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java
index 359e9a7..92f4cf7 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java
@@ -21,6 +21,7 @@
package me.lucko.spark.common;
import me.lucko.spark.common.command.sender.CommandSender;
+import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.sampler.tick.TickHook;
import me.lucko.spark.common.sampler.tick.TickReporter;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDump.java b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDump.java
index f2c1c72..975dbb3 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDump.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDump.java
@@ -20,14 +20,15 @@
package me.lucko.spark.common.heapdump;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.nio.file.Path;
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
/**
* Utility for creating .hprof memory heap snapshots.
*/
diff --git a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
index f7a562c..61ffd71 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java
@@ -21,7 +21,7 @@
package me.lucko.spark.common.heapdump;
import me.lucko.spark.common.command.sender.CommandSender;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.proto.SparkProtos;
import me.lucko.spark.proto.SparkProtos.HeapData;
import me.lucko.spark.proto.SparkProtos.HeapEntry;
diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectionMonitor.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectionMonitor.java
index d750b1a..f66d43b 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectionMonitor.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/memory/GarbageCollectionMonitor.java
@@ -22,15 +22,16 @@ package me.lucko.spark.common.monitor.memory;
import com.sun.management.GarbageCollectionNotificationInfo;
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.management.ListenerNotFoundException;
import javax.management.Notification;
import javax.management.NotificationEmitter;
import javax.management.NotificationListener;
import javax.management.openmbean.CompositeData;
-import java.lang.management.GarbageCollectorMXBean;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.List;
public class GarbageCollectionMonitor implements NotificationListener, AutoCloseable {
diff --git a/spark-common/src/main/java/me/lucko/spark/common/platform/AbstractPlatformInfo.java b/spark-common/src/main/java/me/lucko/spark/common/platform/AbstractPlatformInfo.java
new file mode 100644
index 0000000..645d5b2
--- /dev/null
+++ b/spark-common/src/main/java/me/lucko/spark/common/platform/AbstractPlatformInfo.java
@@ -0,0 +1,17 @@
+package me.lucko.spark.common.platform;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryUsage;
+
+public abstract class AbstractPlatformInfo implements PlatformInfo {
+
+ @Override
+ public int getNCpus() {
+ return Runtime.getRuntime().availableProcessors();
+ }
+
+ @Override
+ public MemoryUsage getHeapUsage() {
+ return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
+ }
+}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/PlatformInfo.java b/spark-common/src/main/java/me/lucko/spark/common/platform/PlatformInfo.java
index 8ff3997..20015dd 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/PlatformInfo.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/platform/PlatformInfo.java
@@ -18,13 +18,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package me.lucko.spark.common;
+package me.lucko.spark.common.platform;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
+import me.lucko.spark.proto.SparkProtos.MemoryData;
import me.lucko.spark.proto.SparkProtos.PlatformData;
+import java.lang.management.MemoryUsage;
+
public interface PlatformInfo {
Type getType();
@@ -35,8 +35,12 @@ public interface PlatformInfo {
String getMinecraftVersion();
+ int getNCpus();
+
+ MemoryUsage getHeapUsage();
+
default Data toData() {
- return new Data(getType(), getName(), getVersion(), getMinecraftVersion());
+ return new Data(getType(), getName(), getVersion(), getMinecraftVersion(), getNCpus(), getHeapUsage());
}
enum Type {
@@ -51,25 +55,7 @@ public interface PlatformInfo {
}
public PlatformData.Type toProto() {
- return type;
- }
-
- public static Type fromProto(PlatformData.Type proto) {
- for (Type type : values()) {
- if (type.toProto() == proto) {
- return type;
- }
- }
-
- return null;
- }
-
- public String getName() {
- return super.name().toLowerCase();
- }
-
- public static Type fromName(String name) {
- return valueOf(name.toUpperCase());
+ return this.type;
}
}
@@ -78,47 +64,57 @@ public interface PlatformInfo {
private final String name;
private final String version;
private final String minecraftVersion;
+ private final int nCpus;
+ private final MemoryUsage heapUsage;
- public Data(Type type, String name, String version, String minecraftVersion) {
+ public Data(Type type, String name, String version, String minecraftVersion, int nCpus, MemoryUsage heapUsage) {
this.type = type;
this.name = name;
this.version = version;
this.minecraftVersion = minecraftVersion;
+ this.nCpus = nCpus;
+ this.heapUsage = heapUsage;
}
public Type getType() {
- return type;
+ return this.type;
}
public String getName() {
- return name;
+ return this.name;
}
public String getVersion() {
- return version;
+ return this.version;
}
public String getMinecraftVersion() {
- return minecraftVersion;
+ return this.minecraftVersion;
}
- // TODO: decide if necessary
- public JsonObject serialize() {
- JsonObject server = new JsonObject();
- server.add("type", new JsonPrimitive(this.type.toString().toLowerCase()));
- server.add("name", new JsonPrimitive(this.name));
- server.add("version", new JsonPrimitive(this.version));
- if (this.minecraftVersion != null) {
- server.add("minecraftVersion", new JsonPrimitive(this.minecraftVersion));
- }
- return server;
+ public int getNCpus() {
+ return this.nCpus;
+ }
+
+ public MemoryUsage getHeapUsage() {
+ return this.heapUsage;
+ }
+
+ private static MemoryData toProto(MemoryUsage usage) {
+ return MemoryData.newBuilder()
+ .setUsed(usage.getUsed())
+ .setCommitted(usage.getCommitted())
+ .setMax(usage.getMax())
+ .build();
}
public PlatformData toProto() {
PlatformData.Builder proto = PlatformData.newBuilder()
.setType(this.type.toProto())
.setName(this.name)
- .setVersion(this.version);
+ .setVersion(this.version)
+ .setNCpus(this.nCpus)
+ .setHeapUsage(toProto(this.heapUsage));
if (this.minecraftVersion != null) {
proto.setMinecraftVersion(this.minecraftVersion);
@@ -126,20 +122,5 @@ public interface PlatformInfo {
return proto.build();
}
-
- // TODO: decide if necessary
- public static PlatformInfo.Data deserialize(JsonElement element) {
- JsonObject serverObject = element.getAsJsonObject();
- Type type = Type.fromName(serverObject.get("type").getAsJsonPrimitive().getAsString());
- String name = serverObject.get("name").getAsJsonPrimitive().getAsString();
- String version = serverObject.get("version").getAsJsonPrimitive().getAsString();
- String minecraftVersion;
- if (serverObject.has("minecraftVersion")) {
- minecraftVersion = serverObject.get("minecraftVersion").getAsJsonPrimitive().getAsString();
- } else {
- minecraftVersion = null;
- }
- return new PlatformInfo.Data(type, name, version, minecraftVersion);
- }
}
}
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java
index cc72ca7..e772cb3 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/Sampler.java
@@ -23,7 +23,7 @@ package me.lucko.spark.common.sampler;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import me.lucko.spark.common.command.sender.CommandSender;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.PlatformInfo;
import me.lucko.spark.common.sampler.aggregator.DataAggregator;
import me.lucko.spark.common.sampler.aggregator.SimpleDataAggregator;
import me.lucko.spark.common.sampler.aggregator.TickedDataAggregator;
diff --git a/spark-common/src/main/proto/spark/spark.proto b/spark-common/src/main/proto/spark/spark.proto
index fbb6250..f06c097 100644
--- a/spark-common/src/main/proto/spark/spark.proto
+++ b/spark-common/src/main/proto/spark/spark.proto
@@ -16,12 +16,21 @@ message CommandSenderData {
}
}
+message MemoryData {
+ int64 used = 1;
+ int64 committed = 2;
+ int64 max = 3;
+}
+
message PlatformData {
Type type = 1;
string name = 2;
string version = 3;
string minecraft_version = 4; // optional
+ int32 n_cpus = 5;
+ MemoryData heapUsage = 6;
+
enum Type {
SERVER = 0;
CLIENT = 1;
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricPlatformInfo.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricPlatformInfo.java
index f585585..d5613e7 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricPlatformInfo.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricPlatformInfo.java
@@ -20,13 +20,12 @@
package me.lucko.spark.fabric;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.AbstractPlatformInfo;
import net.fabricmc.loader.api.FabricLoader;
import java.util.Optional;
-public class FabricPlatformInfo implements PlatformInfo {
-
+public class FabricPlatformInfo extends AbstractPlatformInfo {
private final Type type;
public FabricPlatformInfo(Type type) {
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java
index d6e10e5..9c2fbe4 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricClientSparkPlugin.java
@@ -27,9 +27,13 @@ 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.platform.PlatformInfo;
import me.lucko.spark.common.sampler.tick.TickHook;
-import me.lucko.spark.fabric.*;
+import me.lucko.spark.fabric.FabricCommandSender;
+import me.lucko.spark.fabric.FabricPlatformInfo;
+import me.lucko.spark.fabric.FabricSparkGameHooks;
+import me.lucko.spark.fabric.FabricSparkMod;
+import me.lucko.spark.fabric.FabricTickHook;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.server.command.CommandOutput;
diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java
index 1483c6d..6e8e9c1 100644
--- a/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java
+++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/plugin/FabricServerSparkPlugin.java
@@ -26,7 +26,7 @@ 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.platform.PlatformInfo;
import me.lucko.spark.common.sampler.tick.TickHook;
import me.lucko.spark.fabric.FabricCommandSender;
import me.lucko.spark.fabric.FabricPlatformInfo;
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
index 0544072..344882b 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgePlatformInfo.java
@@ -20,12 +20,11 @@
package me.lucko.spark.forge;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.AbstractPlatformInfo;
import net.minecraftforge.versions.forge.ForgeVersion;
import net.minecraftforge.versions.mcp.MCPVersion;
-public class ForgePlatformInfo implements PlatformInfo {
-
+public class ForgePlatformInfo extends AbstractPlatformInfo {
private final Type type;
public ForgePlatformInfo(Type type) {
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 278e838..66fd3ab 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,10 +27,14 @@ 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.platform.PlatformInfo;
import me.lucko.spark.common.sampler.tick.TickHook;
import me.lucko.spark.common.sampler.tick.TickReporter;
-import me.lucko.spark.forge.*;
+import me.lucko.spark.forge.ForgeCommandSender;
+import me.lucko.spark.forge.ForgePlatformInfo;
+import me.lucko.spark.forge.ForgeSparkMod;
+import me.lucko.spark.forge.ForgeTickHook;
+import me.lucko.spark.forge.ForgeTickReporter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.command.ICommandSource;
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 c433c95..3978ba4 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,10 +27,14 @@ 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.platform.PlatformInfo;
import me.lucko.spark.common.sampler.tick.TickHook;
import me.lucko.spark.common.sampler.tick.TickReporter;
-import me.lucko.spark.forge.*;
+import me.lucko.spark.forge.ForgeCommandSender;
+import me.lucko.spark.forge.ForgePlatformInfo;
+import me.lucko.spark.forge.ForgeSparkMod;
+import me.lucko.spark.forge.ForgeTickHook;
+import me.lucko.spark.forge.ForgeTickReporter;
import net.minecraft.command.CommandSource;
import net.minecraft.command.ICommandSource;
import net.minecraft.entity.player.PlayerEntity;
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
index be0e09d..6cad3cb 100644
--- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java
+++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SpongePlatformInfo.java
@@ -20,11 +20,17 @@
package me.lucko.spark.sponge;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.AbstractPlatformInfo;
+import org.spongepowered.api.Game;
import org.spongepowered.api.Platform;
-import org.spongepowered.api.Sponge;
-public class SpongePlatformInfo implements PlatformInfo {
+public class SpongePlatformInfo extends AbstractPlatformInfo {
+ private final Game game;
+
+ public SpongePlatformInfo(Game game) {
+ this.game = game;
+ }
+
@Override
public Type getType() {
return Type.SERVER;
@@ -37,11 +43,11 @@ public class SpongePlatformInfo implements PlatformInfo {
@Override
public String getVersion() {
- return Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getVersion().orElse("unknown");
+ return this.game.getPlatform().getContainer(Platform.Component.IMPLEMENTATION).getVersion().orElse("unknown");
}
@Override
public String getMinecraftVersion() {
- return Sponge.getPlatform().getMinecraftVersion().getName();
+ return this.game.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 0c61b0f..d2c842a 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,7 +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.platform.PlatformInfo;
import me.lucko.spark.common.sampler.ThreadDumper;
import me.lucko.spark.common.sampler.tick.TickHook;
import org.spongepowered.api.Game;
@@ -127,7 +127,7 @@ public class SpongeSparkPlugin implements SparkPlugin {
@Override
public PlatformInfo getPlatformInfo() {
- return new SpongePlatformInfo();
+ return new SpongePlatformInfo(this.game);
}
private static final class SparkCommand implements CommandCallable {
diff --git a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityPlatformInfo.java b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityPlatformInfo.java
index 81fa21c..4750181 100644
--- a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityPlatformInfo.java
+++ b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocityPlatformInfo.java
@@ -21,10 +21,9 @@
package me.lucko.spark.velocity;
import com.velocitypowered.api.proxy.ProxyServer;
-import me.lucko.spark.common.PlatformInfo;
-
-public class VelocityPlatformInfo implements PlatformInfo {
+import me.lucko.spark.common.platform.AbstractPlatformInfo;
+public class VelocityPlatformInfo extends AbstractPlatformInfo {
private final ProxyServer proxy;
public VelocityPlatformInfo(ProxyServer proxy) {
diff --git a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java
index ba59ad4..798f4f1 100644
--- a/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java
+++ b/spark-velocity/src/main/java/me/lucko/spark/velocity/VelocitySparkPlugin.java
@@ -32,7 +32,7 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import me.lucko.spark.common.SparkPlatform;
import me.lucko.spark.common.SparkPlugin;
-import me.lucko.spark.common.PlatformInfo;
+import me.lucko.spark.common.platform.PlatformInfo;
import org.checkerframework.checker.optional.qual.MaybePresent;
import java.nio.file.Path;