Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-25 15:50:19 +01:00
Fix a couple of protocol issues
Dieser Commit ist enthalten in:
Ursprung
029d3a2044
Commit
5be8452d1f
@ -24,15 +24,16 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Handshake handshake = (Handshake) packet;
|
Handshake handshake = (Handshake) packet;
|
||||||
connection.setProtocolVersion(handshake.getProtocolVersion());
|
|
||||||
switch (handshake.getNextStatus()) {
|
switch (handshake.getNextStatus()) {
|
||||||
case 1:
|
case 1:
|
||||||
// Status protocol
|
// Status protocol
|
||||||
connection.setState(StateRegistry.STATUS);
|
connection.setState(StateRegistry.STATUS);
|
||||||
|
connection.setProtocolVersion(handshake.getProtocolVersion());
|
||||||
connection.setSessionHandler(new StatusSessionHandler(connection));
|
connection.setSessionHandler(new StatusSessionHandler(connection));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
connection.setState(StateRegistry.LOGIN);
|
connection.setState(StateRegistry.LOGIN);
|
||||||
|
connection.setProtocolVersion(handshake.getProtocolVersion());
|
||||||
if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) {
|
if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) {
|
||||||
connection.closeWith(Disconnect.create(TextComponent.of("Unsupported client")));
|
connection.closeWith(Disconnect.create(TextComponent.of("Unsupported client")));
|
||||||
return;
|
return;
|
||||||
|
@ -11,6 +11,8 @@ import com.velocitypowered.proxy.protocol.packets.StatusResponse;
|
|||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
import com.velocitypowered.proxy.data.ServerPing;
|
import com.velocitypowered.proxy.data.ServerPing;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.ByteBufUtil;
|
||||||
|
|
||||||
public class StatusSessionHandler implements MinecraftSessionHandler {
|
public class StatusSessionHandler implements MinecraftSessionHandler {
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
@ -43,4 +45,9 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
response.setStatus(VelocityServer.GSON.toJson(ping));
|
response.setStatus(VelocityServer.GSON.toJson(ping));
|
||||||
connection.write(response);
|
connection.write(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleUnknown(ByteBuf buf) {
|
||||||
|
throw new IllegalStateException("Unknown data " + ByteBufUtil.hexDump(buf));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,17 +45,13 @@ public enum StateRegistry {
|
|||||||
map(0x04, MINECRAFT_1_12_1));
|
map(0x04, MINECRAFT_1_12_1));
|
||||||
|
|
||||||
CLIENTBOUND.register(Chat.class, Chat::new,
|
CLIENTBOUND.register(Chat.class, Chat::new,
|
||||||
map(0x0F, MINECRAFT_1_11),
|
map(0x0F, MINECRAFT_1_11));
|
||||||
map(0x0F, MINECRAFT_1_12));
|
|
||||||
CLIENTBOUND.register(Disconnect.class, Disconnect::new,
|
CLIENTBOUND.register(Disconnect.class, Disconnect::new,
|
||||||
map(0x1A, MINECRAFT_1_11),
|
map(0x1A, MINECRAFT_1_11));
|
||||||
map(0x1A, MINECRAFT_1_12));
|
|
||||||
CLIENTBOUND.register(KeepAlive.class, KeepAlive::new,
|
CLIENTBOUND.register(KeepAlive.class, KeepAlive::new,
|
||||||
map(0x1F, MINECRAFT_1_11),
|
map(0x1F, MINECRAFT_1_11));
|
||||||
map(0x1F, MINECRAFT_1_12));
|
|
||||||
CLIENTBOUND.register(JoinGame.class, JoinGame::new,
|
CLIENTBOUND.register(JoinGame.class, JoinGame::new,
|
||||||
map(0x23, MINECRAFT_1_11),
|
map(0x23, MINECRAFT_1_11));
|
||||||
map(0x23, MINECRAFT_1_12));
|
|
||||||
CLIENTBOUND.register(Respawn.class, Respawn::new,
|
CLIENTBOUND.register(Respawn.class, Respawn::new,
|
||||||
map(0x33, MINECRAFT_1_11),
|
map(0x33, MINECRAFT_1_11),
|
||||||
map(0x34, MINECRAFT_1_12),
|
map(0x34, MINECRAFT_1_12),
|
||||||
@ -87,7 +83,7 @@ public enum StateRegistry {
|
|||||||
private static final IntObjectMap<int[]> LINKED_PROTOCOL_VERSIONS = new IntObjectHashMap<>();
|
private static final IntObjectMap<int[]> LINKED_PROTOCOL_VERSIONS = new IntObjectHashMap<>();
|
||||||
|
|
||||||
static {
|
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, new int[] { MINECRAFT_1_12_1 });
|
||||||
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, new int[] { MINECRAFT_1_12_2 });
|
LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, new int[] { MINECRAFT_1_12_2 });
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren