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:
parent
f95f594967
commit
3067032f1b
1 changed files with 2 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue