def create(packet_type): packet = PacketBuffer() packet.put_long(PACKET_HEAD) if packet_type == PacketType.Info: packet.put_string(RequestType.Info) elif packet_type == PacketType.Challenge: packet.put_byte(RequestType.Players) packet.put_long(RequestType.Challenge) elif packet_type == PacketType.Players: packet.put_byte(RequestType.Players) elif packet_type == PacketType.Rules: packet.put_byte(RequestType.Rules) else: return None return packet