mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Reply to ClientboundStartConfigurationPacket
This commit is contained in:
parent
411a25c614
commit
039a9f4ab5
1 changed files with 8 additions and 4 deletions
|
@ -18,6 +18,7 @@ import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundDi
|
||||||
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket;
|
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket;
|
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundStartConfigurationPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundStartConfigurationPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundConfigurationAcknowledgedPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
|
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundHelloPacket;
|
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundHelloPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginCompressionPacket;
|
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginCompressionPacket;
|
||||||
|
@ -90,7 +91,6 @@ public class ClientListener extends SessionAdapter {
|
||||||
session.enableEncryption(protocol.enableEncryption(key));
|
session.enableEncryption(protocol.enableEncryption(key));
|
||||||
} else if (packet instanceof ClientboundGameProfilePacket) {
|
} else if (packet instanceof ClientboundGameProfilePacket) {
|
||||||
session.send(new ServerboundLoginAcknowledgedPacket());
|
session.send(new ServerboundLoginAcknowledgedPacket());
|
||||||
protocol.setState(ProtocolState.CONFIGURATION);
|
|
||||||
} else if (packet instanceof ClientboundLoginDisconnectPacket) {
|
} else if (packet instanceof ClientboundLoginDisconnectPacket) {
|
||||||
session.disconnect(((ClientboundLoginDisconnectPacket) packet).getReason());
|
session.disconnect(((ClientboundLoginDisconnectPacket) packet).getReason());
|
||||||
} else if (packet instanceof ClientboundLoginCompressionPacket) {
|
} else if (packet instanceof ClientboundLoginCompressionPacket) {
|
||||||
|
@ -120,7 +120,7 @@ public class ClientListener extends SessionAdapter {
|
||||||
} else if (packet instanceof ClientboundDisconnectPacket) {
|
} else if (packet instanceof ClientboundDisconnectPacket) {
|
||||||
session.disconnect(((ClientboundDisconnectPacket) packet).getReason());
|
session.disconnect(((ClientboundDisconnectPacket) packet).getReason());
|
||||||
} else if (packet instanceof ClientboundStartConfigurationPacket) {
|
} else if (packet instanceof ClientboundStartConfigurationPacket) {
|
||||||
protocol.setState(ProtocolState.CONFIGURATION);
|
session.send(new ServerboundConfigurationAcknowledgedPacket());
|
||||||
}
|
}
|
||||||
} else if (protocol.getState() == ProtocolState.CONFIGURATION) {
|
} else if (protocol.getState() == ProtocolState.CONFIGURATION) {
|
||||||
if (packet instanceof ClientboundFinishConfigurationPacket) {
|
if (packet instanceof ClientboundFinishConfigurationPacket) {
|
||||||
|
@ -131,9 +131,9 @@ public class ClientListener extends SessionAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void packetSent(Session session, Packet packet) {
|
public void packetSent(Session session, Packet packet) {
|
||||||
|
MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
|
||||||
if (packet instanceof ClientIntentionPacket) {
|
if (packet instanceof ClientIntentionPacket) {
|
||||||
// Once the HandshakePacket has been sent, switch to the next protocol mode.
|
// Once the HandshakePacket has been sent, switch to the next protocol mode.
|
||||||
MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
|
|
||||||
protocol.setState(this.targetState);
|
protocol.setState(this.targetState);
|
||||||
|
|
||||||
if (this.targetState == ProtocolState.LOGIN) {
|
if (this.targetState == ProtocolState.LOGIN) {
|
||||||
|
@ -142,8 +142,12 @@ public class ClientListener extends SessionAdapter {
|
||||||
} else {
|
} else {
|
||||||
session.send(new ServerboundStatusRequestPacket());
|
session.send(new ServerboundStatusRequestPacket());
|
||||||
}
|
}
|
||||||
|
} else if (packet instanceof ServerboundLoginAcknowledgedPacket) {
|
||||||
|
protocol.setState(ProtocolState.CONFIGURATION); // LOGIN -> CONFIGURATION
|
||||||
} else if (packet instanceof ServerboundFinishConfigurationPacket) {
|
} else if (packet instanceof ServerboundFinishConfigurationPacket) {
|
||||||
((MinecraftProtocol) session.getPacketProtocol()).setState(ProtocolState.GAME);
|
protocol.setState(ProtocolState.GAME); // CONFIGURATION -> GAME
|
||||||
|
} else if (packet instanceof ServerboundConfigurationAcknowledgedPacket) {
|
||||||
|
protocol.setState(ProtocolState.CONFIGURATION); // GAME -> CONFIGURATION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue