Skip to content

Commit

Permalink
Disconnect Reason fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaileke committed Sep 17, 2024
1 parent 05d41d4 commit 744a13f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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;
}
_ => {}
}
}
Expand Down Expand Up @@ -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;
}
_ => {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/game/disconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn decode(bytes: Vec<u8>) -> 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();
Expand Down

0 comments on commit 744a13f

Please sign in to comment.