use bare SectionProxy, remove UDP

bare SectionProxy won't throw KeyError when there's no [Treepuncher]
section in config and we're trying to access fields in it: we want
default value to be returned so it can fallback accordingly
This commit is contained in:
əlemi 2022-05-10 01:30:39 +02:00
parent f95f594967
commit 3067032f1b
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -62,7 +62,7 @@ class Treepuncher(
authenticator : AuthInterface
def opt(k:str, required=False, default=None) -> Any:
v = kwargs.get(k) or self.config['Treepuncher'].get(k) or default
v = kwargs.get(k) or self.cfg.get(k) or default
if not v and required:
raise MissingParameterError(f"Missing configuration parameter '{k}'")
return v
@ -86,7 +86,6 @@ class Treepuncher(
super().__init__(
opt('server', required=True),
use_udp=opt('use_udp', default=False),
online_mode=online_mode,
authenticator=authenticator
)
@ -120,7 +119,7 @@ class Treepuncher(
@property
def cfg(self) -> SectionProxy:
return self.config["Treepuncher"]
return SectionProxy(self.config, "Treepuncher")
@property
def playerName(self) -> str: