public function onEncryptionResponsePacket(EncryptionResponsePacket $packet)
    {
        //if we don't have a verifiyToken sent yet then the packet has been sent without us sending a request, disconnect client
        if(null === $this->verifyToken) {
            $this->disconnectClient((new DisconnectPacket())->setReason('Packet received out of order'));
            return;
        }

        //get the verify token from the packet it and decrypt it using our key
        $verifyToken = $this->certificate->getPrivateKey()->decrypt($packet->getToken());

        //if it isn't the same as our token then encryption failed, disconnect the client
        if($verifyToken != $this->verifyToken) {
            $this->disconnectClient((new DisconnectPacket())->setReason('Invalid validation token'));
            return;
        }

        //decrypt the shared secret from the packet and decrypt it using our key
        $secret = $this->certificate->getPrivateKey()->decrypt($packet->getSecret());

        //enable encryption using the client generated secret
        $this->enableAES($secret);

        //generate a login hash the same as the client for the session server request
        $publicKey = $this->certificate->getPublicKey()->getPublicKey();
        $publicKey = base64_decode(substr($publicKey, 28, -26)); //cut out the start and end lines of the key
        $loginHash = $this->serverID . $secret . $publicKey;
        $loginHash = self::sha1($loginHash);

        //create a new Yggdrasil for checking against Mojang
        $yggdrasil = new DefaultYggdrasil();

        try {
            //ask Mojang if the user has sent a join request, throws exception on failure
            $response = $yggdrasil->hasJoined($this->username, $loginHash);

            //get and set the clients UUID from the response
            $this->uuid = $response->getUuid();

            //trigger the login success with the disconnect packet
            $disconnect = new DisconnectPacket();
            $this->emit('login_success', [$this, $disconnect]);

            //if no reason was set after the event then set a default
            if($disconnect->getReasonJSON() === null) {
                $disconnect->setReason("No kick reason supplied");
            }

            //disconnect the client
            $this->disconnectClient($disconnect);
        } catch (Exception $ex) {
            echo "{$this->username} failed authentication with Mojang session servers\n";
            //exception occured checking against Mojang
            $this->disconnectClient((new DisconnectPacket())->setReason("Error Authenticating with Mojang servers"));
        }
    }