don't stop if already stopped
This commit is contained in:
parent
ca45980bcd
commit
022ed83187
2 changed files with 5 additions and 2 deletions
|
@ -88,7 +88,8 @@ class MinecraftClient:
|
|||
await self._handshake(ConnectionState.STATUS)
|
||||
return await self._status(ping)
|
||||
finally:
|
||||
await self.dispatcher.disconnect()
|
||||
if self.dispatcher.connected:
|
||||
await self.dispatcher.disconnect()
|
||||
|
||||
async def join(self, host:str="", port:int=0, proto:int=0):
|
||||
if self.online_mode:
|
||||
|
@ -99,7 +100,8 @@ class MinecraftClient:
|
|||
if await self._login():
|
||||
await self._play()
|
||||
finally:
|
||||
await self.dispatcher.disconnect()
|
||||
if self.dispatcher.connected:
|
||||
await self.dispatcher.disconnect()
|
||||
|
||||
async def _handshake(self, state:ConnectionState):
|
||||
await self.dispatcher.write(
|
||||
|
|
|
@ -249,6 +249,7 @@ class Dispatcher:
|
|||
await self._incoming.put(packet)
|
||||
if self.state != ConnectionState.PLAY:
|
||||
await self._incoming.join() # During play we can pre-process packets
|
||||
|
||||
except (asyncio.TimeoutError, TimeoutError):
|
||||
self.logger.error("Connection timed out")
|
||||
await self.disconnect(block=False)
|
||||
|
|
Loading…
Reference in a new issue