Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Add player versions and sample pipelines to dump
Dieser Commit ist enthalten in:
Ursprung
4067107b52
Commit
0ae64203f5
@ -19,7 +19,7 @@ package com.viaversion.viaversion.bukkit.commands;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -42,10 +42,10 @@ public class BukkitCommandSender implements ViaCommandSender {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Entity) {
|
||||||
return ((Player) sender).getUniqueId();
|
return ((Entity) sender).getUniqueId();
|
||||||
} else {
|
} else {
|
||||||
return UUID.fromString(getName());
|
return new UUID(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class BungeeCommandSender implements ViaCommandSender {
|
|||||||
if (sender instanceof ProxiedPlayer) {
|
if (sender instanceof ProxiedPlayer) {
|
||||||
return ((ProxiedPlayer) sender).getUniqueId();
|
return ((ProxiedPlayer) sender).getUniqueId();
|
||||||
} else {
|
} else {
|
||||||
return UUID.fromString(getName());
|
return new UUID(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,13 @@ package com.viaversion.viaversion.commands.defaultsubs;
|
|||||||
|
|
||||||
import com.google.common.io.CharStreams;
|
import com.google.common.io.CharStreams;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||||
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
import com.viaversion.viaversion.api.command.ViaSubCommand;
|
||||||
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.dump.DumpTemplate;
|
import com.viaversion.viaversion.dump.DumpTemplate;
|
||||||
import com.viaversion.viaversion.dump.VersionInfo;
|
import com.viaversion.viaversion.dump.VersionInfo;
|
||||||
import com.viaversion.viaversion.util.GsonUtil;
|
import com.viaversion.viaversion.util.GsonUtil;
|
||||||
@ -34,7 +37,12 @@ import java.io.OutputStream;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class DumpSubCmd extends ViaSubCommand {
|
public class DumpSubCmd extends ViaSubCommand {
|
||||||
@ -64,14 +72,13 @@ public class DumpSubCmd extends ViaSubCommand {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Map<String, Object> configuration = Via.getPlatform().getConfigurationProvider().getValues();
|
Map<String, Object> configuration = Via.getPlatform().getConfigurationProvider().getValues();
|
||||||
|
DumpTemplate template = new DumpTemplate(version, configuration, Via.getPlatform().getDump(), Via.getManager().getInjector().getDump(), getPlayerSample(sender.getUUID()));
|
||||||
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
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
HttpURLConnection con = null;
|
HttpURLConnection con;
|
||||||
try {
|
try {
|
||||||
con = (HttpURLConnection) new URL("https://dump.viaversion.com/documents").openConnection();
|
con = (HttpURLConnection) new URL("https://dump.viaversion.com/documents").openConnection();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -125,4 +132,50 @@ public class DumpSubCmd extends ViaSubCommand {
|
|||||||
private String getUrl(String id) {
|
private String getUrl(String id) {
|
||||||
return String.format("https://dump.viaversion.com/%s", id);
|
return String.format("https://dump.viaversion.com/%s", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JsonObject getPlayerSample(UUID senderUuid) {
|
||||||
|
JsonObject playerSample = new JsonObject();
|
||||||
|
// Player versions
|
||||||
|
JsonObject versions = new JsonObject();
|
||||||
|
playerSample.add("versions", versions);
|
||||||
|
Map<ProtocolVersion, Integer> playerVersions = new TreeMap<>((o1, o2) -> ProtocolVersion.getIndex(o2) - ProtocolVersion.getIndex(o1));
|
||||||
|
for (UserConnection connection : Via.getManager().getConnectionManager().getConnections()) {
|
||||||
|
ProtocolVersion protocolVersion = ProtocolVersion.getProtocol(connection.getProtocolInfo().getProtocolVersion());
|
||||||
|
playerVersions.compute(protocolVersion, (v, num) -> num != null ? num + 1 : 1);
|
||||||
|
}
|
||||||
|
for (Map.Entry<ProtocolVersion, Integer> entry : playerVersions.entrySet()) {
|
||||||
|
versions.addProperty(entry.getKey().getName(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pipeline of sender
|
||||||
|
Set<List<String>> pipelines = new HashSet<>();
|
||||||
|
UserConnection senderConnection = Via.getAPI().getConnection(senderUuid);
|
||||||
|
if (senderConnection != null && senderConnection.getChannel() != null) {
|
||||||
|
pipelines.add(senderConnection.getChannel().pipeline().names());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other pipelines if different ones are found (3 max)
|
||||||
|
for (UserConnection connection : Via.getManager().getConnectionManager().getConnections()) {
|
||||||
|
if (connection.getChannel() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> names = connection.getChannel().pipeline().names();
|
||||||
|
if (pipelines.add(names) && pipelines.size() == 3) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (List<String> pipeline : pipelines) {
|
||||||
|
JsonArray senderPipeline = new JsonArray(pipeline.size());
|
||||||
|
for (String name : pipeline) {
|
||||||
|
senderPipeline.add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSample.add("pipeline-" + i++, senderPipeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
return playerSample;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
package com.viaversion.viaversion.dump;
|
package com.viaversion.viaversion.dump;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DumpTemplate {
|
public class DumpTemplate {
|
||||||
@ -26,12 +28,14 @@ public class DumpTemplate {
|
|||||||
private final Map<String, Object> configuration;
|
private final Map<String, Object> configuration;
|
||||||
private final JsonObject platformDump;
|
private final JsonObject platformDump;
|
||||||
private final JsonObject injectionDump;
|
private final JsonObject injectionDump;
|
||||||
|
private final JsonObject playerSample;
|
||||||
|
|
||||||
public DumpTemplate(VersionInfo versionInfo, Map<String, Object> configuration, JsonObject platformDump, JsonObject injectionDump) {
|
public DumpTemplate(VersionInfo versionInfo, Map<String, Object> configuration, JsonObject platformDump, JsonObject injectionDump, JsonObject playerSample) {
|
||||||
this.versionInfo = versionInfo;
|
this.versionInfo = versionInfo;
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.platformDump = platformDump;
|
this.platformDump = platformDump;
|
||||||
this.injectionDump = injectionDump;
|
this.injectionDump = injectionDump;
|
||||||
|
this.playerSample = playerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VersionInfo getVersionInfo() {
|
public VersionInfo getVersionInfo() {
|
||||||
@ -49,4 +53,8 @@ public class DumpTemplate {
|
|||||||
public JsonObject getInjectionDump() {
|
public JsonObject getInjectionDump() {
|
||||||
return injectionDump;
|
return injectionDump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonObject getPlayerSample() {
|
||||||
|
return playerSample;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class SpongeCommandSender implements ViaCommandSender {
|
|||||||
if (source instanceof Identifiable) {
|
if (source instanceof Identifiable) {
|
||||||
return ((Identifiable) source).uniqueId();
|
return ((Identifiable) source).uniqueId();
|
||||||
} else {
|
} else {
|
||||||
return UUID.fromString(getName());
|
return new UUID(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class VelocityCommandSender implements ViaCommandSender {
|
|||||||
if (source instanceof Player) {
|
if (source instanceof Player) {
|
||||||
return ((Player) source).getUniqueId();
|
return ((Player) source).getUniqueId();
|
||||||
}
|
}
|
||||||
return UUID.fromString(getName());
|
return new UUID(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren