Paste #77370: RTP

Date: 2020/11/11 12:38:48 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


rtp_command:
    type: command
    name: rtp
    debug: false
    description: randomly teleports you
    usage: /rtp
    permission: behr.essentials.rtp
    script:
    # % ██ [ define integers/ invalid blocks ] ██
        - define distance 6000
        - define blocks <list[grass_block]>

    # % ██ [ check world ] ██
        - if <player.world.name> == Hub:
            - narrate "<&c>You can't use this in <&a>Hub! <&a>Available in: <&f>(<&6>Resource<&f>, <&6>Survival<&f>)"
            - stop

    # % ██ [ check for cooldown ] ██
        - if <player.has_flag[behr.essentials.rtpcooldown]>:
            - narrate "<&c>You must wait: <&6><player.flag[behr.essentials.rtpcooldown].expiration.formatted> <&c>to rtp again."
            - stop

        - flag player behr.essentials.rtpcooldown duration:5s

        - define x <util.random.int[-<[distance]>].to[<[distance]>]>
        - define z <util.random.int[-<[distance]>].to[<[distance]>]>
        - chunkload <location[<[x]>,0,<[z]>,<player.world.name>].chunk> duration:1t
        - define locationBlock <location[<[x]>,-1,[<[z]>]].material.name>

        - while <[locationBlock]> == <[blocks]>:
            - if <material.name.contains[blocks]>:
                - define x <util.random.int[-<[distance]>].to[<[distance]>]>
                - define z <util.random.int[-<[distance]>].to[<[distance]>]>
                - chunkload <location[<[x]>,0,<[z]>,<player.world.name>].chunk> duration:1t
                - announce "&cInvalid location, retrying."
            - else:
                - define loc <location[<[x]>,0,<[z]>,<player.world.name>]>
                - narrate "<&a>Teleporting you randomly!"
                - teleport <[loc].with_y[300].with_pitch[90]>