public static void OnPlayerPreLogin(PlayerPreLoginEventArgs args)
 {
     PlayerPreLogin?.Invoke(args);
 }
        private void LoginPacketHandle(LoginPacket pk)
        {
            if (this.IsPreLogined)
            {
                return;
            }

            if (pk.Protocol < ProtocolInfo.CLIENT_PROTOCOL)
            {
                this.SendPlayStatus(PlayStatusPacket.LOGIN_FAILED_CLIENT);
                this.Close("disconnectionScreen.outdatedClient");
                return;
            }
            else if (pk.Protocol > ProtocolInfo.CLIENT_PROTOCOL)
            {
                this.SendPlayStatus(PlayStatusPacket.LOGIN_FAILED_SERVER);
                this.Close("disconnectionScreen.outdatedServer");
                return;
            }

            this.LoginData   = pk.LoginData;
            this.Name        = pk.LoginData.DisplayName;
            this.DisplayName = this.Name;
            this.Uuid        = this.LoginData.ClientUUID;

            this.ClientData = pk.ClientData;
            this.Skin       = this.ClientData.Skin;

            Player[] players = Server.Instance.GetPlayers();
            for (int i = 0; i < players.Length; ++i)
            {
                if (players[i].GetHashCode() != this.GetHashCode())
                {
                    if (players[i].Name == this.Name)
                    {
                        this.Close("disconnectionScreen.loggedinOtherLocation");
                        return;
                    }
                }
            }

            if (this.Ban)
            {
                this.Close("You are banned");
                return;
            }

            if (this.BanIp)
            {
                this.Close("You are IP banned");
                return;
            }

            if (Server.Instance.Whitelist)
            {
                if (!this.Whitelist)
                {
                    this.Close("Server is whitelisted");
                    return;
                }
            }

            PlayerPreLoginEventArgs playerPreLoginEvent = new PlayerPreLoginEventArgs(this, "");

            PlayerEvents.OnPlayerPreLogin(playerPreLoginEvent);
            if (playerPreLoginEvent.IsCancel)
            {
                this.Close(playerPreLoginEvent.KickMessage);
                return;
            }

            this.IsPreLogined = true;

            this.SendPlayStatus(PlayStatusPacket.LOGIN_SUCCESS);

            ResourcePacksInfoPacket resourcePacksInfoPacket = new ResourcePacksInfoPacket();

            this.SendPacket(resourcePacksInfoPacket);
        }