3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Add subplatform versions to dumps

Dieser Commit ist enthalten in:
KennyTV 2020-04-17 20:52:55 +02:00
Ursprung e3821e1741
Commit 0f90efa05f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 26 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -14,6 +14,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.TabCompleteThread;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ViaIdleThread; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ViaIdleThread;
import us.myles.ViaVersion.update.UpdateUtil; import us.myles.ViaVersion.update.UpdateUtil;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -25,6 +26,7 @@ public class ViaManager {
private final ViaInjector injector; private final ViaInjector injector;
private final ViaCommandHandler commandHandler; private final ViaCommandHandler commandHandler;
private final ViaPlatformLoader loader; private final ViaPlatformLoader loader;
private final Set<String> subPlatforms = new HashSet<>();
private boolean debug; private boolean debug;
@Builder @Builder
@ -170,6 +172,16 @@ public class ViaManager {
return loader; return loader;
} }
/**
* Returns a mutable set of self-added subplatform version strings.
* This set is expanded by the subplatform itself (e.g. ViaBackwards), and may not contain all running ones.
*
* @return mutable set of subplatform versions
*/
public Set<String> getSubPlatforms() {
return subPlatforms;
}
public UserConnection getConnection(UUID playerUUID) { public UserConnection getConnection(UUID playerUUID) {
return platform.getConnectionManager().getConnectedClient(playerUUID); return platform.getConnectionManager().getConnectedClient(playerUUID);
} }

Datei anzeigen

@ -18,7 +18,7 @@ import java.io.InvalidObjectException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
@ -34,10 +34,9 @@ public class DumpSubCmd extends ViaSubCommand {
return "Dump information about your server, this is helpful if you report bugs."; return "Dump information about your server, this is helpful if you report bugs.";
} }
@Override @Override
public boolean execute(final ViaCommandSender sender, String[] args) { public boolean execute(ViaCommandSender sender, String[] args) {
final VersionInfo version = new VersionInfo( VersionInfo version = new VersionInfo(
System.getProperty("java.version"), System.getProperty("java.version"),
System.getProperty("os.name"), System.getProperty("os.name"),
ProtocolRegistry.SERVER_PROTOCOL, ProtocolRegistry.SERVER_PROTOCOL,
@ -45,12 +44,13 @@ public class DumpSubCmd extends ViaSubCommand {
Via.getPlatform().getPlatformName(), Via.getPlatform().getPlatformName(),
Via.getPlatform().getPlatformVersion(), Via.getPlatform().getPlatformVersion(),
Via.getPlatform().getPluginVersion(), Via.getPlatform().getPluginVersion(),
ViaManager.class.getPackage().getImplementationVersion() ViaManager.class.getPackage().getImplementationVersion(),
Via.getManager().getSubPlatforms()
); );
Map<String, Object> configuration = Via.getPlatform().getConfigurationProvider().getValues(); Map<String, Object> configuration = Via.getPlatform().getConfigurationProvider().getValues();
final DumpTemplate template = new DumpTemplate(version, configuration, Via.getPlatform().getDump(), Via.getManager().getInjector().getDump()); DumpTemplate template = new DumpTemplate(version, configuration, Via.getPlatform().getDump(), Via.getManager().getInjector().getDump());
Via.getPlatform().runAsync(new Runnable() { Via.getPlatform().runAsync(new Runnable() {
@Override @Override
@ -71,7 +71,7 @@ public class DumpSubCmd extends ViaSubCommand {
con.setDoOutput(true); con.setDoOutput(true);
OutputStream out = con.getOutputStream(); OutputStream out = con.getOutputStream();
out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(Charset.forName("UTF-8"))); out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(StandardCharsets.UTF_8));
out.close(); out.close();
if (con.getResponseCode() == 429) { if (con.getResponseCode() == 429) {

Datei anzeigen

@ -11,9 +11,10 @@ public class VersionInfo {
private final String platformVersion; private final String platformVersion;
private final String pluginVersion; private final String pluginVersion;
private final String implementationVersion; private final String implementationVersion;
private final Set<String> subPlatforms;
public VersionInfo(String javaVersion, String operatingSystem, int serverProtocol, Set<Integer> enabledProtocols, public VersionInfo(String javaVersion, String operatingSystem, int serverProtocol, Set<Integer> enabledProtocols,
String platformName, String platformVersion, String pluginVersion, String implementationVersion) { String platformName, String platformVersion, String pluginVersion, String implementationVersion, Set<String> subPlatforms) {
this.javaVersion = javaVersion; this.javaVersion = javaVersion;
this.operatingSystem = operatingSystem; this.operatingSystem = operatingSystem;
this.serverProtocol = serverProtocol; this.serverProtocol = serverProtocol;
@ -22,6 +23,7 @@ public class VersionInfo {
this.platformVersion = platformVersion; this.platformVersion = platformVersion;
this.pluginVersion = pluginVersion; this.pluginVersion = pluginVersion;
this.implementationVersion = implementationVersion; this.implementationVersion = implementationVersion;
this.subPlatforms = subPlatforms;
} }
public String getJavaVersion() { public String getJavaVersion() {
@ -55,5 +57,9 @@ public class VersionInfo {
public String getImplementationVersion() { public String getImplementationVersion() {
return implementationVersion; return implementationVersion;
} }
public Set<String> getSubPlatforms() {
return subPlatforms;
}
} }