From e2459f7982ac04b4ff51c43d960adef679912054 Mon Sep 17 00:00:00 2001 From: Francesco Tolomei <80046572+f-tlm@users.noreply.github.com> Date: Thu, 7 Apr 2022 00:05:14 +0200 Subject: [PATCH] WIP: authentication rework --- src/treepuncher/__main__.py | 2 +- src/treepuncher/treepuncher.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/treepuncher/__main__.py b/src/treepuncher/__main__.py index 00e00de..5f46101 100644 --- a/src/treepuncher/__main__.py +++ b/src/treepuncher/__main__.py @@ -84,7 +84,7 @@ def main(): client_secret=args.secret, redirect_uri=args.uri ) - + enabled_addons = set(a.lower() for a in args.add) for addon in addons: if addon.__name__.lower() in enabled_addons: diff --git a/src/treepuncher/treepuncher.py b/src/treepuncher/treepuncher.py index 5652321..73345b6 100644 --- a/src/treepuncher/treepuncher.py +++ b/src/treepuncher/treepuncher.py @@ -17,6 +17,7 @@ from aiocraft.client import MinecraftClient from aiocraft.util import helpers from aiocraft.mc.packet import Packet from aiocraft.mc.definitions import ConnectionState +from aiocraft.mc.auth import AuthInterface, MicrosoftAuthenticator, MojangAuthenticator from aiocraft.mc.proto import PacketSetCompression, PacketKickDisconnect from aiocraft.mc.proto.play.clientbound import PacketKeepAlive from aiocraft.mc.proto.play.serverbound import PacketKeepAlive as PacketKeepAliveResponse @@ -97,8 +98,17 @@ class Treepuncher( _processing : bool - def __init__(self, name:str, *args, config_file:str=None, notifier:Notifier=None, **kwargs): - super().__init__(*args, **kwargs) + def __init__( + self, + name:str, + server:str, + config_file:str=None, + notifier:Notifier=None, + online_mode:bool=True, + authenticator:Optional[AuthInterface]=None, + **kwargs + ): + super().__init__(server, online_mode=online_mode, authenticator=authenticator, username=name) self.ctx = dict() self.name = name