def make_add_player_packet(self, context, display_name=True): packet_buffer = PacketBuffer() packet = PlayerListItemPacket( context=context, action_type=PlayerListItemPacket.AddPlayerAction, actions=[ PlayerListItemPacket.AddPlayerAction( uuid=fake_uuid, name='goodmonson', properties=[ PlayerListItemPacket.PlayerProperty( name='property1', value='value1', signature=None), PlayerListItemPacket.PlayerProperty( name='property2', value='value2', signature='gm') ], gamemode=42, ping=69, display_name='Goodmonson' if display_name else None ), ], ) if display_name: self.assertEqual( str(packet), "0x%02X PlayerListItemPacket(" "action_type=AddPlayerAction, actions=[AddPlayerAction(" "uuid=%r, name='goodmonson', properties=[PlayerProperty(" "name='property1', value='value1', signature=None), " "PlayerProperty(name='property2', value='value2', " "signature='gm')], gamemode=42, ping=69, " "display_name='Goodmonson')])" % (packet.id, fake_uuid)) packet.write_fields(packet_buffer) packet_buffer.reset_cursor() return packet_buffer
def make_add_player_packet(context, display_name=True): packet_buffer = PacketBuffer() PlayerListItemPacket( context=context, action_type=PlayerListItemPacket.AddPlayerAction, actions=[ PlayerListItemPacket.AddPlayerAction( uuid=fake_uuid, name='goodmonson', properties=[ PlayerListItemPacket.PlayerProperty(name='property1', value='value1', signature=None), PlayerListItemPacket.PlayerProperty(name='property2', value='value2', signature='gm') ], gamemode=42, ping=69, display_name='Goodmonson' if display_name else None), ], ).write_fields(packet_buffer) packet_buffer.reset_cursor() return packet_buffer