diff --git a/evennia/commands/command.py b/evennia/commands/command.py index f676df49bb..26c1ca7e8e 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -623,6 +623,22 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th )[0] return settings.CLIENT_DEFAULT_WIDTH + def _get_account_option(self, option): + """ + Retrieve the value of a specified account option. + + Args: + option (str): The name of the option to retrieve. + + Returns: + The value of the specified account option if the account exists, + otherwise the default value from settings.OPTIONS_ACCOUNT_DEFAULT. + + """ + if self.account: + return self.account.options.get(option) + return settings.OPTIONS_ACCOUNT_DEFAULT.get(option) + def styled_table(self, *args, **kwargs): """ Create an EvTable styled by on user preferences. @@ -638,8 +654,8 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th or incomplete and ready for use with `.add_row` or `.add_collumn`. """ - border_color = self.account.options.get("border_color") - column_color = self.account.options.get("column_names_color") + border_color = self._get_account_option("border_color") + column_color = self._get_account_option("column_names_color") colornames = ["|%s%s|n" % (column_color, col) for col in args] @@ -699,9 +715,9 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th """ colors = dict() - colors["border"] = self.account.options.get("border_color") - colors["headertext"] = self.account.options.get("%s_text_color" % mode) - colors["headerstar"] = self.account.options.get("%s_star_color" % mode) + colors["border"] = self._get_account_option("border_color") + colors["headertext"] = self._get_account_option("%s_text_color" % mode) + colors["headerstar"] = self._get_account_option("%s_star_color" % mode) width = width or self.client_width() if edge_character: @@ -722,7 +738,7 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th else: center_string = "" - fill_character = self.account.options.get("%s_fill" % mode) + fill_character = self._get_account_option("%s_fill" % mode) remain_fill = width - len(center_string) if remain_fill % 2 == 0: diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index 7a081d02ad..a420d88d41 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -1484,7 +1484,7 @@ class CmdName(ObjManipCommand): obj = None if self.lhs_objs: objname = self.lhs_objs[0]["name"] - if objname.startswith("*"): + if objname.startswith("*") and caller.account: # account mode obj = caller.account.search(objname.lstrip("*")) if obj: diff --git a/evennia/commands/default/general.py b/evennia/commands/default/general.py index 3899cfcd93..af70f2b467 100644 --- a/evennia/commands/default/general.py +++ b/evennia/commands/default/general.py @@ -189,7 +189,8 @@ class CmdNick(COMMAND_DEFAULT_CLASS): if "clearall" in switches: caller.nicks.clear() - caller.account.nicks.clear() + if caller.account: + caller.account.nicks.clear() caller.msg("Cleared all nicks.") return @@ -789,15 +790,18 @@ class CmdAccess(COMMAND_DEFAULT_CLASS): hierarchy_full = settings.PERMISSION_HIERARCHY string = "\n|wPermission Hierarchy|n (climbing):\n %s" % ", ".join(hierarchy_full) - if self.caller.account.is_superuser: + if caller.account and caller.account.is_superuser: cperms = "" pperms = "" else: cperms = ", ".join(caller.permissions.all()) - pperms = ", ".join(caller.account.permissions.all()) + if caller.account: + pperms = ", ".join(caller.account.permissions.all()) + else: + pperms = "" string += "\n|wYour access|n:" string += f"\nCharacter |c{caller.key}|n: {cperms}" - if utils.inherits_from(caller, DefaultObject): + if utils.inherits_from(caller, DefaultObject) and caller.account: string += f"\nAccount |c{caller.account.key}|n: {pperms}" caller.msg(string)