From a7aa25578440ee26e620fa4e2596e3b49a2183d3 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 20 Oct 2021 21:38:08 -0400 Subject: [PATCH] Include more vendor information and flags in Geyser dump --- .../command/defaults/DumpCommand.java | 9 ++++- .../org/geysermc/connector/dump/DumpInfo.java | 39 ++++++++++++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java index 0a1c81114..075bfbbcd 100644 --- a/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java +++ b/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java @@ -25,6 +25,8 @@ package org.geysermc.connector.command.defaults; +import com.fasterxml.jackson.core.util.DefaultIndenter; +import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.geysermc.common.PlatformType; @@ -79,10 +81,13 @@ public class DumpCommand extends GeyserCommand { AsteriskSerializer.showSensitive = showSensitive; sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.dump.collecting", sender.getLocale())); - String dumpData = ""; + String dumpData; try { if (offlineDump) { - dumpData = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(new DumpInfo(addLog)); + DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); + // Make arrays easier to read + prettyPrinter.indentArraysWith(new DefaultIndenter(" ", "\n")); + dumpData = MAPPER.writer(prettyPrinter).writeValueAsString(new DumpInfo(addLog)); } else { dumpData = MAPPER.writeValueAsString(new DumpInfo(addLog)); } diff --git a/connector/src/main/java/org/geysermc/connector/dump/DumpInfo.java b/connector/src/main/java/org/geysermc/connector/dump/DumpInfo.java index d6a5f0725..3f566ee26 100644 --- a/connector/src/main/java/org/geysermc/connector/dump/DumpInfo.java +++ b/connector/src/main/java/org/geysermc/connector/dump/DumpInfo.java @@ -31,6 +31,7 @@ import com.github.steveice10.mc.protocol.MinecraftConstants; import com.google.common.hash.Hashing; import com.google.common.io.ByteSource; import com.google.common.io.Files; +import com.nukkitx.protocol.bedrock.BedrockPacketCodec; import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import lombok.AllArgsConstructor; @@ -48,8 +49,13 @@ import org.geysermc.floodgate.util.FloodgateInfoHolder; import java.io.File; import java.io.IOException; -import java.net.*; +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.UnknownHostException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; @@ -68,6 +74,7 @@ public class DumpInfo { private final RamInfo ramInfo; private LogsInfo logsInfo; private final BootstrapDumpInfo bootstrapInfo; + private final FlagsInfo flagsInfo; public DumpInfo(boolean addLog) { this.versionInfo = new VersionInfo(); @@ -113,12 +120,16 @@ public class DumpInfo { } this.bootstrapInfo = GeyserConnector.getInstance().getBootstrap().getDumpInfo(); + + this.flagsInfo = new FlagsInfo(); } @Getter public static class VersionInfo { private final String name; private final String version; + private final String javaName; + private final String javaVendor; private final String javaVersion; private final String architecture; private final String operatingSystem; @@ -130,7 +141,9 @@ public class DumpInfo { VersionInfo() { this.name = GeyserConnector.NAME; this.version = GeyserConnector.VERSION; - this.javaVersion = System.getProperty("java.version"); + this.javaName = System.getProperty("java.vm.name"); + this.javaVendor = System.getProperty("java.vendor"); + this.javaVersion = ManagementFactory.getRuntimeMXBean().getVmVersion(); // Gives a little more to the version we can use over the system property // Usually gives Java architecture but still may be helpful. this.architecture = System.getProperty("os.arch"); this.operatingSystem = System.getProperty("os.name"); @@ -171,14 +184,16 @@ public class DumpInfo { @Getter public static class MCInfo { - private final String bedrockVersion; - private final int bedrockProtocol; + private final List bedrockVersions; + private final List bedrockProtocols; + private final int defaultBedrockProtocol; private final String javaVersion; private final int javaProtocol; MCInfo() { - this.bedrockVersion = BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion(); - this.bedrockProtocol = BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion(); + this.bedrockVersions = BedrockProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getMinecraftVersion).toList(); + this.bedrockProtocols = BedrockProtocol.SUPPORTED_BEDROCK_CODECS.stream().map(BedrockPacketCodec::getProtocolVersion).toList(); + this.defaultBedrockProtocol = BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion(); this.javaVersion = MinecraftConstants.GAME_VERSION; this.javaProtocol = MinecraftConstants.PROTOCOL_VERSION; } @@ -230,4 +245,16 @@ public class DumpInfo { this.max = Runtime.getRuntime().maxMemory() / MEGABYTE; } } + + /** + * E.G. `-Xmx1024M` - all runtime JVM flags on this machine + */ + @Getter + public static class FlagsInfo { + private final List flags; + + FlagsInfo() { + this.flags = ManagementFactory.getRuntimeMXBean().getInputArguments(); + } + } }