Date: 2018/03/01 09:06:55 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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