fix errors in az-client

This commit is contained in:
mat 2022-07-29 15:38:33 -05:00
parent 1b602d0be7
commit f22a386c78
2 changed files with 9 additions and 9 deletions

View file

@ -18,6 +18,7 @@ use azalea_protocol::{
login::{
serverbound_hello_packet::ServerboundHelloPacket,
serverbound_key_packet::{NonceOrSaltSignature, ServerboundKeyPacket},
ClientboundLoginPacket,
},
ConnectionProtocol, PROTOCOL_VERSION,
},
@ -110,7 +111,7 @@ impl Client {
let packet_result = conn.read().await;
match packet_result {
Ok(packet) => match packet {
LoginPacket::ClientboundHelloPacket(p) => {
ClientboundLoginPacket::ClientboundHelloPacket(p) => {
println!("Got encryption request");
let e = azalea_crypto::encrypt(&p.public_key, &p.nonce).unwrap();
@ -128,21 +129,20 @@ impl Client {
.await;
conn.set_encryption_key(e.secret_key);
}
LoginPacket::ClientboundLoginCompressionPacket(p) => {
ClientboundLoginPacket::ClientboundLoginCompressionPacket(p) => {
println!("Got compression request {:?}", p.compression_threshold);
conn.set_compression_threshold(p.compression_threshold);
}
LoginPacket::ClientboundGameProfilePacket(p) => {
ClientboundLoginPacket::ClientboundGameProfilePacket(p) => {
println!("Got profile {:?}", p.game_profile);
break (conn.game(), p.game_profile);
}
LoginPacket::ClientboundLoginDisconnectPacket(p) => {
ClientboundLoginPacket::ClientboundLoginDisconnectPacket(p) => {
println!("Got disconnect {:?}", p);
}
LoginPacket::ClientboundCustomQueryPacket(p) => {
ClientboundLoginPacket::ClientboundCustomQueryPacket(p) => {
println!("Got custom query {:?}", p);
}
_ => panic!("Unexpected packet {:?}", packet),
},
Err(e) => {
panic!("Error: {:?}", e);

View file

@ -5,7 +5,8 @@ use azalea_protocol::{
handshake::client_intention_packet::ClientIntentionPacket,
status::{
clientbound_status_response_packet::ClientboundStatusResponsePacket,
serverbound_status_request_packet::ServerboundStatusRequestPacket, StatusPacket,
serverbound_status_request_packet::ServerboundStatusRequestPacket,
ClientboundStatusPacket,
},
ConnectionProtocol, PROTOCOL_VERSION,
},
@ -38,7 +39,6 @@ pub async fn ping_server(
let packet = conn.read().await.unwrap();
match packet {
StatusPacket::ClientboundStatusResponsePacket(p) => Ok(p),
_ => Err("Invalid packet type".to_string()),
ClientboundStatusPacket::ClientboundStatusResponsePacket(p) => Ok(p),
}
}