Add move/move_here lock check to tel` command. Resolve #1579

This commit is contained in:
Griatch 2021-10-31 23:41:06 +01:00
parent ef9f80cb84
commit fc3bf04fd8
2 changed files with 19 additions and 1 deletions

View file

@ -106,6 +106,8 @@ Up requirements to Django 3.2+, Twisted 21+
- Change `settings.COMMAND_DEFAULT_ARG_REGEX` default from `None` to a regex meaning that - Change `settings.COMMAND_DEFAULT_ARG_REGEX` default from `None` to a regex meaning that
a space or `/` must separate the cmdname and args. This better fits common expectations. a space or `/` must separate the cmdname and args. This better fits common expectations.
- Add confirmation question to `ban`/`unban` commands. - Add confirmation question to `ban`/`unban` commands.
- Add `move` and `move_here` to `tel` command to optionally allow to limit
teleportation of an object or to a specific destination.
### Evennia 0.9.5 (2019-2020) ### Evennia 0.9.5 (2019-2020)

View file

@ -3356,6 +3356,13 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS):
Teleports an object somewhere. If no object is given, you yourself are Teleports an object somewhere. If no object is given, you yourself are
teleported to the target location. teleported to the target location.
To lock an object from being teleported, set its `move` lock, it will be
checked with the caller. To block
a destination from being teleported to, set the destination's `move_here`
lock - it will be checked with the thing being teleported. Admins and
higher permissions can always teleport.
""" """
key = "tel" key = "tel"
@ -3437,6 +3444,16 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS):
caller.msg("%s is already at %s." % (obj_to_teleport, destination)) caller.msg("%s is already at %s." % (obj_to_teleport, destination))
return return
# check any move-locks
if not (caller.permissions.check("Admin") or obj_to_teleport.access(caller, "move")):
caller.msg(f"{obj_to_teleport} 'move'-lock blocks you from teleporting it anywhere.")
return
if not (caller.permissions.check("Admin")
or destination.access(obj_to_teleport, "move_here")):
caller.msg(f"{destination} 'move_to'-lock blocks {obj_to_teleport} from moving there.")
return
# try the teleport # try the teleport
if not obj_to_teleport.location: if not obj_to_teleport.location:
# teleporting from none-location # teleporting from none-location
@ -3454,7 +3471,6 @@ class CmdTeleport(COMMAND_DEFAULT_CLASS):
caller.msg("Teleportation failed.") caller.msg("Teleportation failed.")
class CmdTag(COMMAND_DEFAULT_CLASS): class CmdTag(COMMAND_DEFAULT_CLASS):
""" """
handles the tags of an object handles the tags of an object