From 2030bfc97b8182257875cc73869bd205f993588b Mon Sep 17 00:00:00 2001 From: alemidev Date: Mon, 18 Apr 2022 20:32:00 +0200 Subject: [PATCH] fixes --- src/aiocraft/dispatcher.py | 6 ++++-- src/aiocraft/mc/auth/microsoft.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/aiocraft/dispatcher.py b/src/aiocraft/dispatcher.py index 9bc6194..98b63bd 100644 --- a/src/aiocraft/dispatcher.py +++ b/src/aiocraft/dispatcher.py @@ -59,6 +59,8 @@ class Dispatcher: self.host = "localhost" self.port = 25565 self._dispatching = False + self._packet_whitelist = None + self._packet_id_whitelist = None @property def is_server(self) -> bool: @@ -113,8 +115,8 @@ class Dispatcher: def set_proto(self, proto:Optional[int]=757) -> 'Dispatcher': self.proto = proto or self.proto - if self._packet_id_whitelist: - self._packet_id_whitelist = set((P(self.proto).id for P in self._packet_whitelist)) if self._packet_whitelist else set() + if self._packet_whitelist: + self._packet_id_whitelist = set((P(self.proto).id for P in self._packet_whitelist)) return self def set_state(self, state:Optional[ConnectionState]=ConnectionState.HANDSHAKING) -> 'Dispatcher': diff --git a/src/aiocraft/mc/auth/microsoft.py b/src/aiocraft/mc/auth/microsoft.py index 97b08f8..2294e39 100644 --- a/src/aiocraft/mc/auth/microsoft.py +++ b/src/aiocraft/mc/auth/microsoft.py @@ -79,7 +79,7 @@ class MicrosoftAuthenticator(AuthInterface): async def refresh(self): if not self.refreshToken: - raise AuthException("Missing refresh token") + raise AuthException("refresh", 404, {"error": "Missing refresh token"}, {}) self.accessToken = await self.authenticate() prof = await self.fetch_profile() self.selectedProfile = GameProfile(id=prof['id'], name=prof['name']) @@ -87,7 +87,7 @@ class MicrosoftAuthenticator(AuthInterface): async def validate(self): if not self.accessToken: - raise AuthException("No access token") + raise AuthException("validate", 404, {"error": "No access token"}, {}) prof = await self.fetch_profile() self.selectedProfile = GameProfile(id=prof['id'], name=prof['name']) logging.info("Session validated : %s", repr(self.selectedProfile))