From 73daac471c46e0ef8270dddb57206d0c3d435a45 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 21 Apr 2024 21:55:59 +0200 Subject: [PATCH] Split up version data in dump --- .../viaversion/dump/VersionInfo.java | 30 +++++++++++++----- .../viaversion/viaversion/util/DumpUtil.java | 23 ++++++++------ .../viaversion/data/mappings-1.20to1.19.4.nbt | Bin 3696 -> 0 bytes 3 files changed, 36 insertions(+), 17 deletions(-) delete mode 100644 common/src/main/resources/assets/viaversion/data/mappings-1.20to1.19.4.nbt diff --git a/common/src/main/java/com/viaversion/viaversion/dump/VersionInfo.java b/common/src/main/java/com/viaversion/viaversion/dump/VersionInfo.java index 3a6a03bbd..65651ee84 100644 --- a/common/src/main/java/com/viaversion/viaversion/dump/VersionInfo.java +++ b/common/src/main/java/com/viaversion/viaversion/dump/VersionInfo.java @@ -17,25 +17,31 @@ */ package com.viaversion.viaversion.dump; +import com.viaversion.viaversion.api.protocol.version.VersionType; import java.util.Set; public class VersionInfo { private final String javaVersion; private final String operatingSystem; - private final String serverProtocol; - private final Set enabledProtocols; + private final VersionType versionType; + private final int serverProtocol; + private final String serverVersion; + private final Set enabledVersions; private final String platformName; private final String platformVersion; private final String pluginVersion; private final String implementationVersion; private final Set subPlatforms; - public VersionInfo(String javaVersion, String operatingSystem, String serverProtocol, Set enabledProtocols, - String platformName, String platformVersion, String pluginVersion, String implementationVersion, Set subPlatforms) { + public VersionInfo(String javaVersion, String operatingSystem, VersionType versionType, int serverProtocol, String serverVersion, + Set enabledVersions, String platformName, String platformVersion, String pluginVersion, String implementationVersion, + Set subPlatforms) { this.javaVersion = javaVersion; this.operatingSystem = operatingSystem; this.serverProtocol = serverProtocol; - this.enabledProtocols = enabledProtocols; + this.versionType = versionType; + this.serverVersion = serverVersion; + this.enabledVersions = enabledVersions; this.platformName = platformName; this.platformVersion = platformVersion; this.pluginVersion = pluginVersion; @@ -51,12 +57,20 @@ public class VersionInfo { return operatingSystem; } - public String getServerProtocol() { + public VersionType getVersionType() { + return versionType; + } + + public int getServerProtocol() { return serverProtocol; } - public Set getEnabledProtocols() { - return enabledProtocols; + public String getServerVersion() { + return serverVersion; + } + + public Set getEnabledVersions() { + return enabledVersions; } public String getPlatformName() { diff --git a/common/src/main/java/com/viaversion/viaversion/util/DumpUtil.java b/common/src/main/java/com/viaversion/viaversion/util/DumpUtil.java index 90fa07b4b..14909a6fa 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/DumpUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/util/DumpUtil.java @@ -23,6 +23,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.platform.ViaPlatform; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.dump.DumpTemplate; import com.viaversion.viaversion.dump.VersionInfo; @@ -56,33 +57,37 @@ public final class DumpUtil { * @return completable future that completes with the url of the dump */ public static CompletableFuture postDump(@Nullable final UUID playerToSample) { + final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion(); + final ViaPlatform platform = Via.getPlatform(); final VersionInfo version = new VersionInfo( System.getProperty("java.version"), System.getProperty("os.name"), - Via.getAPI().getServerVersion().lowestSupportedProtocolVersion().toString(), + protocolVersion.getVersionType(), + protocolVersion.getVersion(), + protocolVersion.getName(), Via.getManager().getProtocolManager().getSupportedVersions().stream().map(ProtocolVersion::toString).collect(Collectors.toCollection(LinkedHashSet::new)), - Via.getPlatform().getPlatformName(), - Via.getPlatform().getPlatformVersion(), - Via.getPlatform().getPluginVersion(), + platform.getPlatformName(), + platform.getPlatformVersion(), + platform.getPluginVersion(), com.viaversion.viaversion.util.VersionInfo.getImplementationVersion(), Via.getManager().getSubPlatforms() ); final Map configuration = ((Config) Via.getConfig()).getValues(); - final DumpTemplate template = new DumpTemplate(version, configuration, Via.getPlatform().getDump(), Via.getManager().getInjector().getDump(), getPlayerSample(playerToSample)); + final DumpTemplate template = new DumpTemplate(version, configuration, platform.getDump(), Via.getManager().getInjector().getDump(), getPlayerSample(playerToSample)); final CompletableFuture result = new CompletableFuture<>(); - Via.getPlatform().runAsync(() -> { + platform.runAsync(() -> { final HttpURLConnection con; try { con = (HttpURLConnection) new URL("https://dump.viaversion.com/documents").openConnection(); } catch (final IOException e) { - Via.getPlatform().getLogger().log(Level.SEVERE, "Error when opening connection to ViaVersion dump service", e); + platform.getLogger().log(Level.SEVERE, "Error when opening connection to ViaVersion dump service", e); result.completeExceptionally(new DumpException(DumpErrorType.CONNECTION, e)); return; } try { con.setRequestProperty("Content-Type", "application/json"); - con.addRequestProperty("User-Agent", "ViaVersion-" + Via.getPlatform().getPlatformName() + "/" + version.getPluginVersion()); + con.addRequestProperty("User-Agent", "ViaVersion-" + platform.getPlatformName() + "/" + version.getPluginVersion()); con.setRequestMethod("POST"); con.setDoOutput(true); @@ -107,7 +112,7 @@ public final class DumpUtil { result.complete(urlForId(output.get("key").getAsString())); } catch (final Exception e) { - Via.getPlatform().getLogger().log(Level.SEVERE, "Error when posting ViaVersion dump", e); + platform.getLogger().log(Level.SEVERE, "Error when posting ViaVersion dump", e); result.completeExceptionally(new DumpException(DumpErrorType.POST, e)); printFailureInfo(con); } diff --git a/common/src/main/resources/assets/viaversion/data/mappings-1.20to1.19.4.nbt b/common/src/main/resources/assets/viaversion/data/mappings-1.20to1.19.4.nbt deleted file mode 100644 index 965e792cf4795a5ef10e7d1d82eb0b490b59908c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3696 zcmbuCX>S`v7{?zU0XL zTq@yvM3fn(t##M8S5&|Pu5vWoW}Oaqs^V!*bnf*GWrdT;QC>v@%O|%|mIZJe0X^^x zQRx^s0T#gn;6d;ZSRyJb0Q+(mTp&7K0?&cJh^m-hz7K+duLYlqMGv_|CQ3&jva=6| z=#eYyIrkzB(+zP+scLdpQ`O}DOsd&}zz4x?MA@_8aqt9q1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