3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 23:30:26 +01:00

Fix a couple of protocol issues

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-07-29 20:53:51 -04:00
Ursprung 029d3a2044
Commit 5be8452d1f
3 geänderte Dateien mit 14 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -24,15 +24,16 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
Handshake handshake = (Handshake) packet;
connection.setProtocolVersion(handshake.getProtocolVersion());
switch (handshake.getNextStatus()) {
case 1:
// Status protocol
connection.setState(StateRegistry.STATUS);
connection.setProtocolVersion(handshake.getProtocolVersion());
connection.setSessionHandler(new StatusSessionHandler(connection));
break;
case 2:
connection.setState(StateRegistry.LOGIN);
connection.setProtocolVersion(handshake.getProtocolVersion());
if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) {
connection.closeWith(Disconnect.create(TextComponent.of("Unsupported client")));
return;

Datei anzeigen

@ -11,6 +11,8 @@ import com.velocitypowered.proxy.protocol.packets.StatusResponse;
import com.velocitypowered.proxy.connection.MinecraftConnection;
import com.velocitypowered.proxy.data.ServerPing;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
public class StatusSessionHandler implements MinecraftSessionHandler {
private final MinecraftConnection connection;
@ -43,4 +45,9 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
response.setStatus(VelocityServer.GSON.toJson(ping));
connection.write(response);
}
@Override
public void handleUnknown(ByteBuf buf) {
throw new IllegalStateException("Unknown data " + ByteBufUtil.hexDump(buf));
}
}

Datei anzeigen

@ -45,17 +45,13 @@ public enum StateRegistry {
map(0x04, MINECRAFT_1_12_1));
CLIENTBOUND.register(Chat.class, Chat::new,
map(0x0F, MINECRAFT_1_11),
map(0x0F, MINECRAFT_1_12));
map(0x0F, MINECRAFT_1_11));
CLIENTBOUND.register(Disconnect.class, Disconnect::new,
map(0x1A, MINECRAFT_1_11),
map(0x1A, MINECRAFT_1_12));
map(0x1A, MINECRAFT_1_11));
CLIENTBOUND.register(KeepAlive.class, KeepAlive::new,
map(0x1F, MINECRAFT_1_11),
map(0x1F, MINECRAFT_1_12));
map(0x1F, MINECRAFT_1_11));
CLIENTBOUND.register(JoinGame.class, JoinGame::new,
map(0x23, MINECRAFT_1_11),
map(0x23, MINECRAFT_1_12));
map(0x23, MINECRAFT_1_11));
CLIENTBOUND.register(Respawn.class, Respawn::new,
map(0x33, MINECRAFT_1_11),
map(0x34, MINECRAFT_1_12),
@ -87,7 +83,7 @@ public enum StateRegistry {
private static final IntObjectMap<int[]> LINKED_PROTOCOL_VERSIONS = new IntObjectHashMap<>();
static {
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_11, new int[] { MINECRAFT_1_11_1 });
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_11, new int[] { MINECRAFT_1_11_1, MINECRAFT_1_12 });
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12, new int[] { MINECRAFT_1_12_1 });
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, new int[] { MINECRAFT_1_12_2 });
}