Skip to content

Commit

Permalink
Add /area_duplicate command
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystalwarrior committed Apr 17, 2024
1 parent 693892e commit 0de3d0b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions server/commands/hubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# Area Creation system
"ooc_cmd_area_create",
"ooc_cmd_area_remove",
"ooc_cmd_area_duplicate",
"ooc_cmd_area_rename",
"ooc_cmd_area_swap",
"ooc_cmd_area_switch",
Expand Down Expand Up @@ -321,6 +322,32 @@ def ooc_cmd_area_remove(client, arg):
"Invalid number of arguments. Use /area_remove <aid>.")


@mod_only(hub_owners=True)
def ooc_cmd_area_duplicate(client, arg):
"""
Duplicate an area, copying all of its properties and evidence.
Usage: /area_duplicate <aid>
"""
args = arg.split()

if len(args) == 1:
try:
area = client.area.area_manager.get_area_by_id(int(args[0]))
name = area.name
data = area.save()
new_area = client.area.area_manager.create_area()
new_area.load(data)
client.area.area_manager.broadcast_area_list()
client.send_ooc(f"Area {name} duplicated!")
except ValueError:
raise ArgumentError("Area ID must be a number.")
except (AreaError, ClientError):
raise
else:
raise ArgumentError(
"Invalid number of arguments. Use /area_duplicate <aid>.")


@mod_only(area_owners=True)
def ooc_cmd_area_rename(client, arg):
"""
Expand Down

0 comments on commit 0de3d0b

Please sign in to comment.