Date: 2018/09/09 00:18:57 UTC-07: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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Town_Version:
type: version
name: dTowny
id: 1
description: "Claiming plugin coded in Denizen."
version: 1.0
File_Handler:
type: world
events:
on server start:
- if <server.has_file[/towns/members.yml]> {
- yaml "load:/towns/members.yml" id:members_loaded
}
else {
- yaml create id:members_loaded
}
on shutdown:
- yaml "savefile:/towns/members.yml" id:members_loaded
Town_Command:
type: command
name: town
aliases:
- t
- towny
description: "Main town command"
usage: "/town help"
script:
- define args li@help|create|delete|join|leave|claim|unclaim|deposit|withdraw|info
- if <def[args].contains[<context.args.get[1]>]> {
- inject locally path:<context.args.get[1]>
}
else {
- inject locally path:help
}
help:
- narrate "<&6>------------- <&e><&l>dTowns Help <&6>-------------"
- narrate ""
- narrate "<&6>/town help » <&e>Display this page."
- narrate "<&6>/town create » <&e>Create a town."
- narrate "<&6>/town delete » <&e>Delete a town."
- narrate "<&6>/town join » <&e>Join a town."
- narrate "<&6>/town leave » <&e>Leave a town."
- narrate "<&6>/town claim » <&e>Claim a chunk."
- narrate "<&6>/town unclaim » <&e>Unclaim a chunk."
- narrate "<&6>/town deposit » <&e>Deposit in the town bank."
- narrate "<&6>/town withdraw » <&e>Withdraw from the town bank."
- narrate "<&6>/town info » <&e>Preview a town info."
- narrate ""
- narrate "<&6>----------------------------------------"
create:
- if <context.args.get[2]> == null {
- narrate "<&6>You need to specify a name, use <&e>/town create <name>"
- queue clear
- if <yaml[members_loaded].read[players-in-town].contains[<player.uuid>]> {
- narrate "<&6>You are already in a town! Leave your town and repeat this command."
- queue clear
}
- if <player.flag[money]> < 100 {
- narrate "<&6>You need 100 Coins to do this! You are lacking <&e><el@100.sub[<player.flag[money]>]><&6>!"
}
//add an if for claimed chunks
- take money qty:100
- yaml id:members_loaded set players-in-town:->:<player.uuid>
- yaml create id:<player.uuid>_town
- yaml id:<player.uuid>_town set name:<context.args.get[2]>
- yaml id:<player.uuid>_town set balance:0
- yaml id:<player.uuid>_town set mayor:<player.uuid>
- yaml id:<player.uuid>_town set chunks:->:<player.location.chunk>
- yaml id:<player.uuid>_town set members:->:<player.uuid>
- announce "<&6><player.name> <&e>has created a town named <&e><yaml[<player.uuid>_town].read[name]><&6>!"
delete:
- if !<server.has_file[/towns/<player.uuid>_town.yml]> {
- narrate "<&6>You do not own a town to delete!"
}
else {
- narrate "<&6>Are you sure you want to delete this town?"
-
}