Paste #81989: WGConverter

Date: 2021/03/14 15:26:16 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#Author: Icecapade
#Date: 2021-03-14
#Version: 1.0
WGConverter:
    type: command
    debug: false
    name: wgtodenizen
    description: converts worldguard regions to useable notables
    usage: /wgtodenizen [world/all] (regionname)
    tab complete:
    - choose "<context.raw_args.to_list.count[ ]>":
        - case 0:
            - if <context.args.first||null> != null:
                - determine <server.worlds.parse[name].include[all].filter[starts_with[<context.args.first>]]>
            - else:
                - determine <server.worlds.parse[name].include[all]>
        - case 1:
            - if <context.args.first> != all && <context.args.get[2]||null> != null:
                - determine <world[<context.args.first>].list_regions.parse[id].filter[starts_with[<context.args.get[2]>]]||null>
            - else if <context.args.first> != all:
                - determine <world[<context.args.first>].list_regions.parse[id]>
    script:
    - choose <context.args.first||null>:
        - case all:
            - narrate "Converting all WorldGuard-regions in useable Denizen notables.." format:WGConverter_format
            - foreach <server.worlds> as:world:
                - foreach <[world].list_regions> as:region:
                    - if <[region].cuboid||null> == null:
                        - narrate "The region <gold><[region].id> <gray>is not a cuboid-shaped region and can not be converted yet. Skipping." format:WGConverter_format
                        - foreach next
                    - note <[region].cuboid> as:WG_<[region].id>
                    - narrate "The region <gold><[region].id> <gray>was sucessfully converted to a cuboid notable called <gold>WG_<[region].id>" format:WGConverter_format
                - wait 1t
        - case null:
            - narrate "Syntax: <gold>/wgtodenizen [<&lt>world_name<&gt>/all] (<&lt>region_name<&gt>)"
        - default:
            - define world <context.args.first>
            - if !<server.worlds.parse[name].contains[<[world]>]>:
                - narrate "This world does not exist." format:WGConverter_format
                - stop
            - define region_name <context.args.get[2]||null>
            - if <[region_name]> == null:
                - narrate "You must specify a region name." format:WGConverter_format
                - stop
            - if !<world[<[world]>].has_region[<[region_name]>]>:
                - narrate "This world does not have a region called <gold><[region_name]>" format:WGConverter_format
                - stop
            - define region <region[<[region_name]>,<[world]>].cuboid||null>
            - if <[region]> == null:
                - narrate "This region is not a cuboid-shaped region and can not be converted yet." format:WGConverter_format
                - stop
            - narrate "The region <gold><[region_name]> <gray>was sucessfully converted to a cuboid notable called <gold>WG_<[region_name]>" format:WGConverter_format
            - note <[region]> as:WG_<[region_name]>
WGConverter_format:
    type: format
    debug: false
    format: <yellow>[WGConverter] <gray><text>