diff --git a/src/client.rs b/src/client.rs index b5293d2..f4909f6 100644 --- a/src/client.rs +++ b/src/client.rs @@ -411,9 +411,8 @@ impl Client { }, BedrockPacketType::Disconnect => { let disconnect = disconnect::decode(stream.get_remaining().unwrap()); - println!("Disconnect (string): {}", String::from_utf8(stream.get_remaining().unwrap()).unwrap()); println!("Reason: {}", disconnect.reason); - if disconnect.skip_message { + if !disconnect.skip_message { println!("Message: {}", disconnect.message.unwrap()); println!("Filtered Message: {}", disconnect.filtered_message.unwrap()); } @@ -472,6 +471,15 @@ impl Client { self.socket.send(&datagram.to_binary()).expect("ClientToServerHandshake Packet Fragment could not be sent"); } }, + BedrockPacketType::Disconnect => { + let disconnect = disconnect::decode(stream.get_remaining().unwrap()); + println!("Reason: {}", disconnect.reason); + if !disconnect.skip_message { + println!("Message: {}", disconnect.message.unwrap()); + println!("Filtered Message: {}", disconnect.filtered_message.unwrap()); + } + should_stop = true; + } _ => {} } } @@ -614,6 +622,15 @@ impl Client { println!("Parameters: {}", parameters.join(" ")); } }, + BedrockPacketType::Disconnect => { + let disconnect = disconnect::decode(stream.get_remaining().unwrap()); + println!("Reason: {}", disconnect.reason); + if !disconnect.skip_message { + println!("Message: {}", disconnect.message.unwrap()); + println!("Filtered Message: {}", disconnect.filtered_message.unwrap()); + } + should_stop = true; + } _ => {} } } diff --git a/src/protocol/game/disconnect.rs b/src/protocol/game/disconnect.rs index bd441c9..7e36fc9 100644 --- a/src/protocol/game/disconnect.rs +++ b/src/protocol/game/disconnect.rs @@ -13,7 +13,7 @@ pub fn decode(bytes: Vec) -> Disconnect { let reason = stream.get_var_int();//bunda da sıkıntı var gibi? let skip_message = stream.get_bool(); - if skip_message { + if !skip_message { let mut length = stream.get_unsigned_var_int(); let message = String::from_utf8(stream.get(length).unwrap()).unwrap(); length = stream.get_unsigned_var_int();