Add platform and environment type to dump

This commit is contained in:
Camotoy 2021-02-05 12:54:35 -05:00
parent 31a7b798f1
commit e8b2bff951

View file

@ -25,6 +25,7 @@
package org.geysermc.platform.fabric; package org.geysermc.platform.fabric;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer; import net.fabricmc.loader.api.ModContainer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@ -34,14 +35,25 @@ import org.geysermc.connector.dump.BootstrapDumpInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@SuppressWarnings("unused") // The way that the dump renders makes them used
public class GeyserFabricDumpInfo extends BootstrapDumpInfo { public class GeyserFabricDumpInfo extends BootstrapDumpInfo {
private String serverIP; private String platformVersion = null;
private int serverPort; private final EnvType environmentType;
private List<ModInfo> mods;
private final String serverIP;
private final int serverPort;
private final List<ModInfo> mods;
public GeyserFabricDumpInfo(MinecraftServer server) { public GeyserFabricDumpInfo(MinecraftServer server) {
super(); super();
for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) {
if (modContainer.getMetadata().getId().equals("fabricloader")) {
this.platformVersion = modContainer.getMetadata().getVersion().getFriendlyString();
break;
}
}
this.environmentType = FabricLoader.getInstance().getEnvironmentType();
if (AsteriskSerializer.showSensitive || (server.getServerIp() == null || server.getServerIp().equals("") || server.getServerIp().equals("0.0.0.0"))) { if (AsteriskSerializer.showSensitive || (server.getServerIp() == null || server.getServerIp().equals("") || server.getServerIp().equals("0.0.0.0"))) {
this.serverIP = server.getServerIp(); this.serverIP = server.getServerIp();
} else { } else {
@ -55,6 +67,14 @@ public class GeyserFabricDumpInfo extends BootstrapDumpInfo {
} }
} }
public String getPlatformVersion() {
return platformVersion;
}
public EnvType getEnvironmentType() {
return environmentType;
}
public String getServerIP() { public String getServerIP() {
return this.serverIP; return this.serverIP;
} }