Paste #15719: Edit of P#15718 - warps

Date: 2015/05/10 17:12:46 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


warps:
  type: world
  events:
    on warps command:
      - determine passively fulfilled
      - inject locally loadYAML
      - define arg1 '<c.args.get[1]>'
      - define arg2 '<c.args.get[2]>'
      - if %arg1% == 'set' {
        - if %arg2% != 'null' {
          - yaml set 'id:warpslist' 'warps.%arg2%:<player.location>'
          - yaml 'savefile:warps/warpslist.yml' 'id:warpslist'
          - narrate "<green>you set <def[arg2]>"
          }
          else {
          - narrate "<red>no name set for this warp"
          }
        }
        else if %arg1% == 'remove' {
        - if %arg2% != 'null' {
          - if !<yaml[warpslist].contains[warps.%arg2%]> {
            - narrate "<red>no such warp named %arg2%"
            - queue clear
            }
          - yaml set 'id:warpslist' 'warps.%arg2%:!'
          - yaml 'savefile:warps/warpslist.yml' 'id:warpslist'
          - narrate "<green>you removed <def[arg2]>"
          }
          else {
          - narrate "<red>no name set for this warp"
          }
        }
        else if %arg1% == 'list' {
        - narrate "<green>valid warp destinations: <yaml[warpslist].list_keys[warps].replace[li@].with[<yellow>].replace[|].with[<&sp>]>"
        }
        else if <yaml[warpslist].contains[warps.%arg1%]> {
        - narrate "<green> teleporting to %arg1%"
        - teleport <player> <yaml[warpslist].read[warps.%arg1%]>
        }
        else {
        - narrate "<red> %arg1% warp dosn't exist"
        }

  loadYAML:
  - if !<yaml.list.contains[warpslist]> {
    - if !<server.has_file[warps/warpslist.yml]> {
      - yaml create 'id:warpslist'
      - yaml 'savefile:warps/warpslist.yml' 'id:warpslist'
      }
      else {
      - yaml 'load:warps/warpslist.yml' 'id:warpslist'
      }
    }