diff --git a/aiocraft/client.py b/aiocraft/client.py index ed11574..b9cacf2 100644 --- a/aiocraft/client.py +++ b/aiocraft/client.py @@ -59,10 +59,10 @@ class Client: ): self.host = host self.port = port + self.options = options or { "reconnect" : True, "rctime" : 5.0, - } self.token = token diff --git a/aiocraft/dispatcher.py b/aiocraft/dispatcher.py index 19bed51..5cdeb37 100644 --- a/aiocraft/dispatcher.py +++ b/aiocraft/dispatcher.py @@ -87,11 +87,12 @@ class Dispatcher: self._dispatching = False if block and self._writer and self._reader: await asyncio.gather(self._writer, self._reader) - if self._up.can_write_eof(): - self._up.write_eof() - self._up.close() - if block: - await self._up.wait_closed() + if self._up: + if self._up.can_write_eof(): + self._up.write_eof() + self._up.close() + if block: + await self._up.wait_closed() self._logger.info("Disconnected") async def connect(self, host:Optional[str] = None, port:Optional[int] = None): diff --git a/aiocraft/mc/identity.py b/aiocraft/mc/identity.py index 3bd2066..0632b2d 100644 --- a/aiocraft/mc/identity.py +++ b/aiocraft/mc/identity.py @@ -102,7 +102,7 @@ class Token: async with sess.post(endpoint, headers=cls.HEADERS, data=json.dumps(data).encode('utf-8')) as res: data = await res.json(content_type=None) logging.info(f"Auth request | {data}") - if res.status != 200: + if res.status >= 400: raise AuthException(f"Action '{endpoint.rsplit('/',1)[1]}' did not succeed") return data