mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
fix: do not send login disconnect packet before switching to login state
This commit is contained in:
parent
8859af87ba
commit
6d5b1ea77e
@ -39,8 +39,21 @@ public final class HandshakeListener {
|
|||||||
|
|
||||||
public static void listener(@NotNull ClientHandshakePacket packet, @NotNull PlayerConnection connection) {
|
public static void listener(@NotNull ClientHandshakePacket packet, @NotNull PlayerConnection connection) {
|
||||||
String address = packet.serverAddress();
|
String address = packet.serverAddress();
|
||||||
|
switch (packet.intent()) {
|
||||||
|
case 1 -> {
|
||||||
|
connection.setClientState(ConnectionState.STATUS);
|
||||||
|
connection.setServerState(ConnectionState.STATUS);
|
||||||
|
}
|
||||||
|
case 2 -> {
|
||||||
|
connection.setClientState(ConnectionState.LOGIN);
|
||||||
|
connection.setServerState(ConnectionState.LOGIN);
|
||||||
|
if (packet.protocolVersion() != MinecraftServer.PROTOCOL_VERSION) {
|
||||||
|
// Incorrect client version
|
||||||
|
disconnect(connection, INVALID_VERSION_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
// Bungee support (IP forwarding)
|
// Bungee support (IP forwarding)
|
||||||
if (BungeeCordProxy.isEnabled() && connection instanceof PlayerSocketConnection socketConnection && packet.intent() == 2) {
|
if (BungeeCordProxy.isEnabled() && connection instanceof PlayerSocketConnection socketConnection) {
|
||||||
final String[] split = address.split("\00");
|
final String[] split = address.split("\00");
|
||||||
|
|
||||||
if (split.length == 3 || split.length == 4) {
|
if (split.length == 3 || split.length == 4) {
|
||||||
@ -104,30 +117,16 @@ public final class HandshakeListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connection instanceof PlayerSocketConnection) {
|
|
||||||
// Give to the connection the server info that the client used
|
|
||||||
((PlayerSocketConnection) connection).refreshServerInformation(address, packet.serverPort(), packet.protocolVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (packet.intent()) {
|
|
||||||
case 1 -> {
|
|
||||||
connection.setClientState(ConnectionState.STATUS);
|
|
||||||
connection.setServerState(ConnectionState.STATUS);
|
|
||||||
}
|
|
||||||
case 2 -> {
|
|
||||||
if (packet.protocolVersion() == MinecraftServer.PROTOCOL_VERSION) {
|
|
||||||
connection.setClientState(ConnectionState.LOGIN);
|
|
||||||
connection.setServerState(ConnectionState.LOGIN);
|
|
||||||
} else {
|
|
||||||
// Incorrect client version
|
|
||||||
disconnect(connection, INVALID_VERSION_TEXT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
// Unexpected error
|
// Unexpected error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connection instanceof PlayerSocketConnection) {
|
||||||
|
// Give to the connection the server info that the client used
|
||||||
|
((PlayerSocketConnection) connection).refreshServerInformation(address, packet.serverPort(), packet.protocolVersion());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void disconnect(@NotNull PlayerConnection connection, @NotNull Component reason) {
|
private static void disconnect(@NotNull PlayerConnection connection, @NotNull Component reason) {
|
||||||
|
Loading…
Reference in New Issue
Block a user