3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00

Split up version data in dump

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-04-21 21:55:59 +02:00
Ursprung f4e9225f85
Commit 73daac471c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
3 geänderte Dateien mit 36 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -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<String> enabledProtocols;
private final VersionType versionType;
private final int serverProtocol;
private final String serverVersion;
private final Set<String> enabledVersions;
private final String platformName;
private final String platformVersion;
private final String pluginVersion;
private final String implementationVersion;
private final Set<String> subPlatforms;
public VersionInfo(String javaVersion, String operatingSystem, String serverProtocol, Set<String> enabledProtocols,
String platformName, String platformVersion, String pluginVersion, String implementationVersion, Set<String> subPlatforms) {
public VersionInfo(String javaVersion, String operatingSystem, VersionType versionType, int serverProtocol, String serverVersion,
Set<String> enabledVersions, String platformName, String platformVersion, String pluginVersion, String implementationVersion,
Set<String> 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<String> getEnabledProtocols() {
return enabledProtocols;
public String getServerVersion() {
return serverVersion;
}
public Set<String> getEnabledVersions() {
return enabledVersions;
}
public String getPlatformName() {

Datei anzeigen

@ -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<String> 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<String, Object> 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<String> 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);
}