use azalea_buf::AzBuf; use azalea_chat::{FormattedText, style::ChatFormatting}; use azalea_protocol_macros::ClientboundGamePacket; #[derive(AzBuf, ClientboundGamePacket, Clone, Debug, PartialEq)] pub struct ClientboundSetPlayerTeam { pub name: String, pub method: Method, } #[derive(AzBuf, Clone, Debug, PartialEq)] pub enum Method { Add((Parameters, PlayerList)), Remove, Change(Parameters), Join(PlayerList), Leave(PlayerList), } #[derive(AzBuf, Clone, Debug, PartialEq)] pub struct Parameters { pub display_name: FormattedText, pub options: u8, pub nametag_visibility: NameTagVisibility, pub collision_rule: CollisionRule, pub color: ChatFormatting, pub player_prefix: FormattedText, pub player_suffix: FormattedText, } #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] pub enum CollisionRule { Always, Never, PushOtherTeams, PushOwnTeam, } #[derive(AzBuf, Clone, Copy, Debug, PartialEq)] pub enum NameTagVisibility { Always, Never, HideForOtherTeams, HideForOwnTeam, } type PlayerList = Vec; #[cfg(test)] mod tests { use std::io::Cursor; use azalea_buf::AzBuf; use crate::packets::game::ClientboundSetPlayerTeam; #[test] fn test_read_set_player_team() { let contents = [ 16, 99, 111, 108, 108, 105, 100, 101, 82, 117, 108, 101, 95, 57, 52, 53, 54, 0, 8, 0, 16, 99, 111, 108, 108, 105, 100, 101, 82, 117, 108, 101, 95, 57, 52, 53, 54, 1, 0, 1, 21, 8, 0, 0, 8, 0, 0, 0, ]; let mut buf = Cursor::new(contents.as_slice()); let packet = ClientboundSetPlayerTeam::azalea_read(&mut buf).unwrap(); println!("{packet:?}"); assert_eq!(buf.position(), contents.len() as u64); } }