Add more info to Fabric's geyser dumps (#4175)

* Added onlineMode, platformName, and Minecraft version to dump - renames platformVersion to loaderVersion since that is more fitting to modded structure

* rename loaderVersion back to platformVersion

* address review by @Konicai

* Fix geyser dump creation (regression from the syntax/annotation PR)
This commit is contained in:
chris 2023-12-06 08:26:20 +01:00 committed by GitHub
parent 95d65350e4
commit c0f6a2b926
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -43,21 +43,27 @@ import java.util.stream.Collectors;
@Getter @Getter
public class GeyserFabricDumpInfo extends BootstrapDumpInfo { public class GeyserFabricDumpInfo extends BootstrapDumpInfo {
private String platformVersion = null; private final String platformName;
private String platformVersion;
private final String minecraftVersion;
private final EnvType environmentType; private final EnvType environmentType;
@AsteriskSerializer.Asterisk(isIp = true) @AsteriskSerializer.Asterisk(isIp = true)
private final String serverIP; private final String serverIP;
private final int serverPort; private final int serverPort;
private final boolean onlineMode;
private final List<ModInfo> mods; private final List<ModInfo> mods;
public GeyserFabricDumpInfo(MinecraftServer server) { public GeyserFabricDumpInfo(MinecraftServer server) {
this.platformName = server.getServerModName();
FabricLoader.getInstance().getModContainer("fabricloader").ifPresent(mod -> FabricLoader.getInstance().getModContainer("fabricloader").ifPresent(mod ->
this.platformVersion = mod.getMetadata().getVersion().getFriendlyString()); this.platformVersion = mod.getMetadata().getVersion().getFriendlyString());
this.minecraftVersion = server.getServerVersion();
this.environmentType = FabricLoader.getInstance().getEnvironmentType(); this.environmentType = FabricLoader.getInstance().getEnvironmentType();
this.serverIP = server.getLocalIp() == null ? "unknown" : server.getLocalIp(); this.serverIP = server.getLocalIp() == null ? "unknown" : server.getLocalIp();
this.serverPort = server.getPort(); this.serverPort = server.getPort();
this.onlineMode = server.usesAuthentication();
this.mods = new ArrayList<>(); this.mods = new ArrayList<>();
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) { for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {

View file

@ -68,6 +68,11 @@ public class AsteriskSerializer extends StdSerializer<Object> implements Context
String asterisk; String asterisk;
boolean isIp; boolean isIp;
@SuppressWarnings("unused") // Used by Jackson for Geyser dumps
public AsteriskSerializer() {
super(Object.class);
}
public AsteriskSerializer(String asterisk, boolean isIp) { public AsteriskSerializer(String asterisk, boolean isIp) {
super(Object.class); super(Object.class);
this.asterisk = asterisk; this.asterisk = asterisk;