allow to specify offline-mode username
This commit is contained in:
parent
4a4f034b33
commit
6d3205c5c6
1 changed files with 4 additions and 1 deletions
|
@ -43,6 +43,7 @@ class MinecraftClient(CallbacksHolder, Runnable):
|
||||||
options:ClientOptions
|
options:ClientOptions
|
||||||
|
|
||||||
_authenticator:AuthInterface
|
_authenticator:AuthInterface
|
||||||
|
_username:str
|
||||||
code:str
|
code:str
|
||||||
|
|
||||||
dispatcher : Dispatcher
|
dispatcher : Dispatcher
|
||||||
|
@ -58,6 +59,7 @@ class MinecraftClient(CallbacksHolder, Runnable):
|
||||||
server:str,
|
server:str,
|
||||||
code:str,
|
code:str,
|
||||||
online_mode:bool = True,
|
online_mode:bool = True,
|
||||||
|
username:str = '',
|
||||||
client_id:str = '', # TODO maybe hardcode defaults?
|
client_id:str = '', # TODO maybe hardcode defaults?
|
||||||
client_secret:str='',
|
client_secret:str='',
|
||||||
redirect_uri:str='http://localhost',
|
redirect_uri:str='http://localhost',
|
||||||
|
@ -75,6 +77,7 @@ class MinecraftClient(CallbacksHolder, Runnable):
|
||||||
self.options = ClientOptions(**kwargs)
|
self.options = ClientOptions(**kwargs)
|
||||||
|
|
||||||
self.code = code
|
self.code = code
|
||||||
|
self._username = username
|
||||||
self._authenticator = MicrosoftAuthenticator(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri)
|
self._authenticator = MicrosoftAuthenticator(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri)
|
||||||
self.online_mode = online_mode
|
self.online_mode = online_mode
|
||||||
|
|
||||||
|
@ -211,7 +214,7 @@ class MinecraftClient(CallbacksHolder, Runnable):
|
||||||
await self.dispatcher.write(
|
await self.dispatcher.write(
|
||||||
PacketLoginStart(
|
PacketLoginStart(
|
||||||
340,
|
340,
|
||||||
username=self._authenticator.selectedProfile.name if self.online_mode else self.code # TODO this is awful
|
username=self._authenticator.selectedProfile.name if self.online_mode else self._username
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue