geforkt von Mirrors/Velocity
Make Velocity's server list ping behavior more conformant.
This fixes pinging with 1.7.x and with certain ping libraries that send the -1 protocol version.
Dieser Commit ist enthalten in:
Ursprung
811d7400c3
Commit
ce6b061b79
@ -179,7 +179,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
@Override
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return ProtocolVersion.UNKNOWN;
|
||||
return ProtocolVersion.LEGACY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,8 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||
public boolean handle(StatusRequest packet) {
|
||||
VelocityConfiguration configuration = server.getConfiguration();
|
||||
|
||||
ProtocolVersion shownVersion = ProtocolVersion.isSupported(connection.getProtocolVersion()) ? connection
|
||||
.getProtocolVersion() :
|
||||
ProtocolVersion.MAXIMUM_VERSION;
|
||||
ProtocolVersion shownVersion = ProtocolVersion.isSupported(connection.getProtocolVersion())
|
||||
? connection.getProtocolVersion() : ProtocolVersion.MAXIMUM_VERSION;
|
||||
ServerPing initialPing = new ServerPing(
|
||||
new ServerPing.Version(shownVersion.getProtocol(),
|
||||
"Velocity " + ProtocolVersion.SUPPORTED_VERSION_STRING),
|
||||
|
@ -200,14 +200,18 @@ public enum StateRegistry {
|
||||
|
||||
public static class PacketRegistry {
|
||||
|
||||
private static final EnumMap<ProtocolVersion, ImmutableList<ProtocolVersion>> LINKED_PROTOCOL_VERSIONS = new EnumMap(ProtocolVersion.class);
|
||||
private static final Map<ProtocolVersion, List<ProtocolVersion>> LINKED_PROTOCOL_VERSIONS
|
||||
= new EnumMap<>(ProtocolVersion.class);
|
||||
|
||||
static {
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9, ImmutableList.of(MINECRAFT_1_9_1, MINECRAFT_1_9_2, MINECRAFT_1_9_4));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9_4, ImmutableList.of(MINECRAFT_1_10, MINECRAFT_1_11, MINECRAFT_1_11_1));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9, ImmutableList.of(MINECRAFT_1_9_1, MINECRAFT_1_9_2,
|
||||
MINECRAFT_1_9_4));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_9_4, ImmutableList.of(MINECRAFT_1_10, MINECRAFT_1_11,
|
||||
MINECRAFT_1_11_1));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12, ImmutableList.of(MINECRAFT_1_12_1));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, ImmutableList.of(MINECRAFT_1_12_2));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_13, ImmutableList.of(MINECRAFT_1_13_1, MINECRAFT_1_13_2));
|
||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_13, ImmutableList.of(MINECRAFT_1_13_1,
|
||||
MINECRAFT_1_13_2));
|
||||
}
|
||||
|
||||
private final Direction direction;
|
||||
@ -217,10 +221,12 @@ public enum StateRegistry {
|
||||
PacketRegistry(Direction direction) {
|
||||
this.direction = direction;
|
||||
|
||||
EnumMap<ProtocolVersion, ProtocolRegistry> mutableVersions = new EnumMap(ProtocolVersion.class);
|
||||
Map<ProtocolVersion, ProtocolRegistry> mutableVersions = new EnumMap<>(ProtocolVersion.class);
|
||||
for (ProtocolVersion version : ProtocolVersion.values()) {
|
||||
if (!version.isLegacy() && !version.isUnknown()) {
|
||||
mutableVersions.put(version, new ProtocolRegistry(version));
|
||||
}
|
||||
}
|
||||
|
||||
this.versions = Collections.unmodifiableMap(mutableVersions);
|
||||
}
|
||||
@ -252,7 +258,7 @@ public enum StateRegistry {
|
||||
}
|
||||
registry.packetClassToId.put(clazz, mapping.id);
|
||||
|
||||
ImmutableList<ProtocolVersion> linked = LINKED_PROTOCOL_VERSIONS.get(mapping.protocolVersion);
|
||||
List<ProtocolVersion> linked = LINKED_PROTOCOL_VERSIONS.get(mapping.protocolVersion);
|
||||
if (linked != null) {
|
||||
links:
|
||||
for (int i = 0; i < linked.size(); i++) {
|
||||
|
@ -56,15 +56,16 @@ public class Handshake implements MinecraftPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
|
||||
this.protocolVersion = ProtocolVersion.getProtocolVersion(ProtocolUtils.readVarInt(buf));
|
||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion ignored) {
|
||||
int realProtocolVersion = ProtocolUtils.readVarInt(buf);
|
||||
this.protocolVersion = ProtocolVersion.getProtocolVersion(realProtocolVersion);
|
||||
this.serverAddress = ProtocolUtils.readString(buf);
|
||||
this.port = buf.readUnsignedShort();
|
||||
this.nextStatus = ProtocolUtils.readVarInt(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
|
||||
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion ignored) {
|
||||
ProtocolUtils.writeVarInt(buf, this.protocolVersion.getProtocol());
|
||||
ProtocolUtils.writeString(buf, this.serverAddress);
|
||||
buf.writeShort(this.port);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren