Paste #4125: RgMgrConfigFilesGenerator

Date: 2014/05/06 10:02:14 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"WGrgInfoCommand":
  type: world
  debug: false
  events:
    on rginfo command:
# example: /rginfo value <player.world.name> town3 owners.players
    - define type '<c.args.get[1]>'
    - define world '<c.args.get[2]>'
    - define regionID '<c.args.get[3]>'
    - define key '<c.args.get[4]>'
    - inject s@WGrgFetch
    - narrate "<def[result]>"
    - inject s@FinishCommand

    on plotsinit command:
    - inject s@WGrgConfigInit

"WGrgFetch":
#
# We can read WorldGuard files! This is just a basic test of how this all works.
#
#    - define type <value || keys>
#    - define world <w@world.name>
#    - define regionID <someRegion>
#    - define key <key in regions.yml>
#    - inject s@WGrgFetch
#    - narrate "do something with <def[result]>"
#
  type: task
  debug: false
  script:
  - yaml 'load:../WorldGuard/worlds/%world%/regions.yml' 'id:WorldGuardRegions_%world%'
  - if <def[type].is[==].to[value]> define result <yaml[WorldGuardRegions_%world%].read[regions.%regionID%.%key%]>
    else if <def[type].is[==].to[keys]> define result <yaml[WorldGuardRegions_%world%].list_keys[regions.%regionID%.%key%]>
    else define result "Unknown type"
  - yaml unload 'id:WorldGuardRegions_%world%'


"WGrgConfigInit":
#
#
  type: task
  debug: true
  script:
    - if !<server.has_file[Plots/config.yml]> {
      - narrate "<&b>Creating Plots config.yml ..."
      - inject s@WGrgConfigInit p:config
      - narrate "<&b>Done!"
      - yaml unload id:PlotsConfig
      }
      else narrate "<&a>config.yml already exists!"

    - if !<server.has_file[Plots/limits.yml]> {
      - narrate "<&b>Creating Plots limits.yml ..."
      - inject s@WGrgConfigInit p:limits
      - narrate "<&b>Done!"
      - yaml unload id:PlotsLimits
      }
      else narrate "<&a>limits.yml already exists!"

    - foreach <server.list_worlds> {
      - define world <def[value].name>
      - if !<server.has_file[Plots/Worlds/%world%.yml]> {
        - narrate "<&b>Creating Plots Worlds/%world%.yml ..."
        - inject s@WGrgConfigInit p:worlds
        - narrate "<&b>Done!"
        - yaml unload id:PlotsRegions_%world%
        }
        else narrate "<&a>%world%.yml already exists!"
      }

  config:
    - yaml create id:PlotsConfig
    - yaml write:version value:0.1 id:PlotsConfig
    - yaml write:BlockPrice value:0.5 split_list id:PlotsConfig
    - yaml write:Refund value:80 split_list id:PlotsConfig
    - yaml write:RemoveFromList value:rent|lease|sell split_list id:PlotsConfig
    - yaml write:CanExtend value:true split_list id:PlotsConfig
    - yaml write:MaxRentExtend value:-1 split_list id:PlotsConfig
    - yaml write:MaxRentExtendDuration value:30d split_list id:PlotsConfig
    - yaml write:ShowLeaseRenewMessage value:true split_list id:PlotsConfig
    - yaml write:ShowRentExpireWarning value:20m split_list id:PlotsConfig
    - yaml write:RollbackOnExpire value:rent|lease split_list id:PlotsConfig
    - yaml write:CanExtend value:true split_list id:PlotsConfig
    - yaml savefile:Plots/config.yml split_list id:PlotsConfig

  limits:
    - yaml create id:PlotsLimits
    - yaml write:version value:0.1 split_list id:PlotsLimits

    - yaml write:global id:PlotsLimits
    - define yamlID 'PlotsLimits'
    - define path 'global'
    - inject s@WGrgConfigInit p:plotTypeLoop

    - yaml write:worlds id:PlotsLimits
    - foreach <server.list_worlds> {
      - define path worlds.<def[value].name>
      - inject s@WGrgConfigInit p:plotTypeLoop
      }

    - yaml write:groups id:PlotsLimits
    - define groups 'citizen|lumberjack|miner|mason|engineer|farmer|alchemist|armorer|blacksmith|enchanter|contractor|electrician|realtor'
    - foreach <def[groups].as_list> {
      - define groupPath groups.<def[value]>
      - foreach <server.list_worlds> {
        - define path <def[groupPath]>.<def[value].name>
        - inject s@WGrgConfigInit p:plotTypeLoop
        }
      }

    - yaml savefile:Plots/limits.yml id:PlotsLimits

  worlds:
    - yaml create id:PlotsRegions_%world%
    - yaml write:version value:0.1 id:PlotsRegions_%world%
    - yaml savefile:Plots/Worlds/%world%.yml id:PlotsRegions_%world%




  plotTypeLoop:
    - define types 'rent|lease|buy|sell'
    - foreach <def[types].as_list> {
      - yaml write:%path%.%value% value:-1 split_list id:%yamlID%
      }