Paste #46756: monkey review

Date: 2018/03/01 09:06:55 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


script:
        - if <def[command].exists.not> {
            - define command join
        }
        - inject s@townsCommand p:prerun instantly
        - if <proc[townsPlayerHasTown].context[<pl>]> {
            - narrate "<&6>You already belong to a Town.<&nl>If you wish to leave it, use <&c><&dq>/t leave<&dq><&6>."
            - playsound <pl> sound:BLOCK_NOTE_HARP
            - queue clear
        }
        # i.e /t join %townName%
        - define townName <def[args].get[1]||null>
        - if <def[townName].matches[null]> {
            - execute as_player "t help join"
            - queue clear
        }
        # gets the uuid/name map
        - define availableTowns <proc[townsServerListTownsMap]>
        - if <def[availableTowns].is_empty> {
            - narrate "<&6>There aren<&sq>t any available Towns to join."
            - playsound <pl> sound:BLOCK_NOTE_HARP
            - queue clear
        }
        # gets the "/name" part of the map, to be matched
        - define availableTownNames <def[availableTowns].get_sub_items[2]>
        # the %townName% from the player's command line is matched
        - define townName <def[availableTownNames].closest_to[<def[townName]>]>
        # then the uuid gets found
        - define town <def[availableTowns].map_find_key[<def[townName]>]> 
        - define flag Towns_invitation_<def[town]>
        - if true {
            - if <player.has_flag[<def[flag]>].not> {
                - narrate "<&6>You need an invitation to join <def[townname]>."
                - playsound <pl> sound:BLOCK_NOTE_HARP
                - queue clear
            }
        }
        - flag player <def[flag]>:!
        - run townsTownAddPlayer def:<player>|<def[town]> instantly