Paste #45513: Untitled Paste

Date: 2017/11/13 05:32:01 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


NODES_FILE_LOADER:
    type: world
    debug: false
    events:
        on server start:
        - if !<server.has_file[dNations/dNodes.yml]> {
            - yaml create id:dNodes
        }
        - yaml "load:dNations/dNodes.yml" id:dNodes
        - yaml "savefile:dNations/dNodes.yml" id:dNodes

NODES_COMMAND:
    type: command
    name: nodes
    script:
    - choose "<context.args.get[1]>":
        - case "create":
            - choose "<context.args.get[2]>":
                - case "copper":
                    - yaml "load:dNations/dNodes.yml" id:dNodes
                    - yaml id:dNodes set mine.quartz_ore:->:<player.location.chunk>"
                    - yaml "savefile:dNations/dNodes.yml" id:dNodes
                    - narrate "<&a>You have successfully created a copper node at <player.location.chunk>!"
                - case "iron":
                    - yaml "load:dNations/dNodes.yml" id:dNodes
                    - yaml id:dNodes set mine.iron_ore:->:<player.location.chunk>"
                    - yaml "savefile:dNations/dNodes.yml" id:dNodes
                    - narrate "<&a>You have successfully created an iron at <player.location.chunk>!"
                - case "gold":
                    - yaml "load:dNations/dNodes.yml" id:dNodes
                    - yaml id:dNodes set mine.gold_ore:->:<player.location.chunk>"
                    - yaml "savefile:dNations/dNodes.yml" id:dNodes
                    - narrate "<&a>You have successfully created a gold node at <player.location.chunk>!"
                - case "sapphire":
                    - yaml "load:dNations/dNodes.yml" id:dNodes
                    - yaml id:dNodes set mine.lapis_ore:->:<player.location.chunk>"
                    - yaml "savefile:dNations/dNodes.yml" id:dNodes
                    - narrate "<&a>You have successfully created a sapphire node at <player.location.chunk>!"
                - case "sparkstone":
                    - yaml "load:dNations/dNodes.yml" id:dNodes
                    - yaml id:dNodes set mine.redstone_ore:->:<player.location.chunk>"
                    - yaml "savefile:dNations/dNodes.yml" id:dNodes
                    - narrate "<&a>You have successfully created a sparkstone node at <player.location.chunk>!"
                - case "emerald":
                    - yaml "load:dNations/dNodes.yml" id:dNodes
                    - yaml id:dNodes set mine.emerald_ore:->:<player.location.chunk>"
                    - yaml "savefile:dNations/dNodes.yml" id:dNodes
                    - narrate "<&a>You have successfully created an emerald node at <player.location.chunk>!"
                - default:
                    - narrate "<&c>That is not a valid node type! Valid node types are:"
                    - narrate "<&c>copper, iron, gold, sapphire, sparkstone."
        - case "remove":
            - foreach <server.list_flags[nodes.]> {
                - if <server.flag[<def[value]>].contains[<player.location.chunk>]> {
                    - flag server <server.flag[nodes.].before[<&dot>]>:->:<player.location.chunk>:!
                }
            }
        - default:
            - narrate "<&c>That is not a valid nodes command! Valid nodes commands are: create, remove."

NODES_REPLENISH:
    type: world
    events:
        on player breaks block:
        - narrate "<yaml[dNodes].read[mine.<context.material.name>].filter[cuboid.contains[<context.location>]].size> > 0"
        - if <yaml[dNodes].read[mine.<context.material.name>].filter[cuboid.contains[<context.location>]].size> > 0 {
            - narrate "replenishing.<context.location>:<context.material>"
            - flag server replenishing.<context.location>:<context.material> duration:30s
        }
        on system time minutely:
        - foreach <server.list_flags[replenishing.]> {
            - narrate "<server.list_flags[replenishing.]>"
            - if <def[value].is_expired> {
                - modifyblock <def[value].after[replenishing.]> <server.flag[<def[value]>]>
                - narrate "<def[value].after[replenishing.]> <server.flag[<def[value]>]>"
            }
        }