Skip to content

Commit

Permalink
use optional method
Browse files Browse the repository at this point in the history
  • Loading branch information
kralverde committed Aug 21, 2024
1 parent 9cf6d40 commit bf698b6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions pumpkin-protocol/src/client/play/c_player_chat_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,14 @@ impl<'a> ClientPacket for CPlayerChatMessage<'a> {
for previous_message in self.previous_messages {
bytebuf.put_var_int(&previous_message.message_id);
if let Some(prev_sig) = previous_message.signature {
// TODO: validate whether this should be None or not
bytebuf.put_slice(prev_sig);
}
}

if let Some(unsigned_component) = self.unsigned_content.as_ref() {
bytebuf.put_bool(true);
bytebuf.put_slice(unsigned_component.encode().as_slice());
} else {
bytebuf.put_bool(false);
}
bytebuf.put_option(&self.unsigned_content, |p, v| {
p.put_slice(v.encode().as_slice())
});

bytebuf.put_var_int(&self.filter_type);
match FilterType::from_i32(self.filter_type.0) {
Expand All @@ -108,12 +106,7 @@ impl<'a> ClientPacket for CPlayerChatMessage<'a> {

bytebuf.put_var_int(&self.chat_type);
bytebuf.put_slice(self.sender_name.encode().as_slice());
if let Some(target) = &self.target_name {
bytebuf.put_bool(true);
bytebuf.put_slice(target.encode().as_slice());
} else {
bytebuf.put_bool(false);
}
bytebuf.put_option(&self.target_name, |p, v| p.put_slice(v.encode().as_slice()));
}
}

Expand Down

0 comments on commit bf698b6

Please sign in to comment.