aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-05-22 10:28:43 +0000
committermat <git@matdoes.dev>2024-05-22 10:28:43 +0000
commit73bcc6639bf44986a4dfaa51e859666a1b8a89f2 (patch)
tree47f5446f14bac668c490f9803c6e28a47247f6b7
parent729d211406c096488a5f7f3df5120393990ac282 (diff)
downloadazalea-drasl-73bcc6639bf44986a4dfaa51e859666a1b8a89f2.tar.xz
fix another edge case in FormattedText::from_nbt_tag that happens with viaversion
-rwxr-xr-xazalea-chat/src/component.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_tab_list_packet.rs19
2 files changed, 21 insertions, 0 deletions
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 508ffc8f..6916928a 100755
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -420,6 +420,8 @@ impl simdnbt::FromNbtTag for FormattedText {
// keybind text components aren't yet supported
trace!("keybind text components aren't yet supported");
return None;
+ } else if let Some(tag) = compound.get("") {
+ return FormattedText::from_nbt_tag(tag);
} else {
let _nbt = compound.get("nbt")?;
let _separator = FormattedText::parse_separator_nbt(compound)?;
diff --git a/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs b/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs
index 47dd1ab2..03557f5a 100755
--- a/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_tab_list_packet.rs
@@ -7,3 +7,22 @@ pub struct ClientboundTabListPacket {
pub header: FormattedText,
pub footer: FormattedText,
}
+
+#[cfg(test)]
+mod tests {
+ use std::io::Cursor;
+
+ use azalea_buf::McBufReadable;
+
+ use super::*;
+
+ #[test]
+ fn test_packet_from_viaversion() {
+ #[rustfmt::skip]
+ let mut bytes = Cursor::new(&[
+ 10, 9, 0, 5, 101, 120, 116, 114, 97, 10, 0, 0, 0, 3, 1, 0, 4, 98, 111, 108, 100, 1, 8, 0, 4, 116, 101, 120, 116, 0, 16, 50, 66, 85, 73, 76, 68, 69, 82, 83, 50, 84, 79, 79, 76, 83, 10, 8, 0, 5, 99, 111, 108, 111, 114, 0, 4, 103, 114, 97, 121, 0, 8, 0, 0, 0, 1, 10, 0, 8, 0, 5, 99, 111, 108, 111, 114, 0, 4, 103, 111, 108, 100, 8, 0, 4, 116, 101, 120, 116, 0, 27, 80, 101, 110, 100, 105, 110, 103, 32, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 32, 116, 111, 32, 50, 98, 50, 116, 10, 0, 8, 0, 4, 116, 101, 120, 116, 0, 1, 10, 0, 10, 9, 0, 5, 101, 120, 116, 114, 97, 10, 0, 0, 0, 1, 8, 0, 5, 99, 111, 108, 111, 114, 0, 4, 103, 111, 108, 100, 8, 0, 4, 116, 101, 120, 116, 0, 72, 84, 104, 105, 115, 32, 97, 99, 99, 111, 117, 110, 116, 32, 104, 97, 115, 32, 112, 114, 105, 111, 114, 105, 116, 121, 32, 115, 116, 97, 116, 117, 115, 32, 97, 110, 100, 32, 119, 105, 108, 108, 32, 98, 101, 32, 112, 108, 97, 99, 101, 100, 32, 105, 110, 32, 97, 32, 115, 104, 111, 114, 116, 101, 114, 32, 113, 117, 101, 117, 101, 46, 10, 0, 8, 0, 4, 116, 101, 120, 116, 0, 1, 10, 0
+ ][..]);
+ let _packet = ClientboundTabListPacket::read_from(&mut bytes).unwrap();
+ assert!(bytes.get_ref()[bytes.position() as usize..].is_empty());
+ }
+}