public static byte[] HubUserlistItem(Leaf x, uint ident, LinkUser user)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(ident);
            packet.WriteString(x, user.OrgName);
            packet.WriteString(x, user.Name);
            packet.WriteString(x, user.Version);
            packet.WriteGuid(user.Guid);
            packet.WriteUInt16(user.FileCount);
            packet.WriteIP(user.ExternalIP);
            packet.WriteIP(user.LocalIP);
            packet.WriteUInt16(user.Port);
            packet.WriteString(x, user.DNS);
            packet.WriteByte((byte)(user.Browsable ? 1 : 0));
            packet.WriteByte(user.Age);
            packet.WriteByte(user.Sex);
            packet.WriteByte(user.Country);
            packet.WriteString(x, user.Region);
            packet.WriteByte((byte)user.Level);
            packet.WriteUInt16(user.Vroom);
            packet.WriteByte((byte)(user.CustomClient ? 1 : 0));
            packet.WriteByte((byte)(user.Muzzled ? 1 : 0));
            packet.WriteByte((byte)(user.WebClient ? 1 : 0));
            packet.WriteByte((byte)(user.Encrypted ? 1 : 0));
            packet.WriteByte((byte)(user.Registered ? 1 : 0));
            packet.WriteByte((byte)(user.Idle ? 1 : 0));
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_USERLIST_ITEM);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafJoin(LinkClient x, IClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, client.OrgName);
            packet.WriteString(x, client.Name);
            packet.WriteString(x, client.Version);
            packet.WriteGuid(client.Guid);
            packet.WriteUInt16(client.FileCount);
            packet.WriteIP(Settings.HideIps ? IPAddress.Parse("0.0.0.0") : client.ExternalIP);
            packet.WriteIP(Settings.HideIps ? IPAddress.Parse("0.0.0.0") : client.LocalIP);
            packet.WriteUInt16(Settings.HideIps ? (ushort)0 : client.DataPort);
            packet.WriteString(x, client.DNS);
            packet.WriteByte((byte)(client.Browsable ? 1 : 0));
            packet.WriteByte(client.Age);
            packet.WriteByte(client.Sex);
            packet.WriteByte(client.Country);
            packet.WriteString(x, client.Region);
            packet.WriteByte((byte)client.Level);
            packet.WriteUInt16(client.Vroom);
            packet.WriteByte((byte)(client.CustomClient ? 1 : 0));
            packet.WriteByte((byte)(client.Muzzled ? 1 : 0));
            packet.WriteByte((byte)(client.WebClient ? 1 : 0));
            packet.WriteByte((byte)(client.Encryption.Mode == EncryptionMode.Encrypted ? 1 : 0));
            packet.WriteByte((byte)(client.Registered ? 1 : 0));
            packet.WriteByte((byte)(client.Idled ? 1 : 0));
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_JOIN);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPong()
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PONG);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafUserlistEnd()
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_USERLIST_END);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafPing()
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_PING);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPrintAll(Leaf x, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PRINT_ALL);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LinkError(LinkError code)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteByte((byte)code);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_ERROR);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubLeafDisconnected(Leaf x, Leaf leaf)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(leaf.Ident);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_LEAF_DISCONNECTED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafPart(LinkClient x, IClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, client.Name, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_PART);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPrintLevel(Leaf x, iconnect.ILevel level, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteByte((byte)level);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PRINT_LEVEL);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPrintVroom(Leaf x, ushort vroom, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt16(vroom);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PRINT_VROOM);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubBrowseData(Leaf x, String browser, byte[] data)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, browser);
            packet.WriteBytes(data);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_BROWSE_DATA);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubNudge(Leaf x, String target, String sender)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, target);
            packet.WriteString(x, sender, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_NUDGE);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubEmoteToLeaf(Leaf x, String sender, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, sender);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_EMOTE_TO_LEAF);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPart(Leaf x, uint ident, LinkUser user)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(ident);
            packet.WriteString(x, user.Name);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PART);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafEmoteText(LinkClient x, String name, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, name);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_EMOTE_TEXT);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPrivateIgnored(Leaf x, String sender, String target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, sender);
            packet.WriteString(x, target, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PRIVATE_IGNORED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafPrintAll(LinkClient x, uint ident, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(ident);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_PRINT_ALL);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafNoAdmin(LinkClient x, uint ident, String name)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(ident);
            packet.WriteString(x, name, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_NO_ADMIN);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafVroomChanged(LinkClient x, IClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, client.Name);
            packet.WriteUInt16(client.Vroom);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_VROOM_CHANGED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafNameChanged(LinkClient x, String old_name, String new_name)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, old_name);
            packet.WriteString(x, new_name, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_NICK_CHANGED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafPersonalMessage(LinkClient x, IClient client)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, client.Name);
            packet.WriteString(x, client.PersonalMessage, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_PERSONAL_MESSAGE);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubPublicToUser(Leaf x, String target, String sender, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, target);
            packet.WriteString(x, sender);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_PUBLIC_TO_USER);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafBrowseData(LinkClient x, uint destination, String browser, byte[] data)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(destination);
            packet.WriteString(x, browser);
            packet.WriteBytes(data);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_BROWSE_DATA);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafPrivateIgnored(LinkClient x, uint sender_ident, String sender, String target)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(sender_ident);
            packet.WriteString(x, sender);
            packet.WriteString(x, target, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_PRIVATE_IGNORED);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafPublicTextToLeaf(LinkClient x, uint target_ident, String name, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(target_ident);
            packet.WriteString(x, name);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_PUBLIC_TO_LEAF);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] LeafNudge(LinkClient x, LinkUser target, String sender)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(target.LinkCredentials.Ident);
            packet.WriteString(x, target.Name);
            packet.WriteString(x, sender, false);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_LEAF_NUDGE);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubIUserBin(Leaf x, String target, String command, byte[] args)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, target);
            packet.WriteString(x, command);
            packet.WriteBytes(args);
            byte[] buf = packet.ToLinkPacket(LinkHub.LinkMsg.MSG_LINK_HUB_IUSER_BIN);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubEmoteText(Leaf x, uint ident, String name, String text)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteUInt32(ident);
            packet.WriteString(x, name);
            packet.WriteString(x, text, false);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_EMOTE_TEXT);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }
        public static byte[] HubScribbleLeaf(Leaf x, String sender, uint height, byte[] img)
        {
            TCPPacketWriter packet = new TCPPacketWriter();

            packet.WriteString(x, sender);
            packet.WriteUInt32(height);
            packet.WriteBytes(img);
            byte[] buf = packet.ToLinkPacket(LinkMsg.MSG_LINK_HUB_SCRIBBLE_LEAF);
            packet = new TCPPacketWriter();
            packet.WriteBytes(buf);
            return(packet.ToAresPacket(TCPMsg.MSG_LINK_PROTO));
        }