Date: 2015/10/27 05:17:04 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Load Prices:
type: world
debug: false
events:
on server start:
- if <server.has_file[/prices.yml]> {
- yaml load:/prices.yml id:prices
- announce to_console "<&a>Loaded existing price list!"
}
else {
- yaml create id:prices
- foreach <server.list_materials.exclude[air|standing_banner|wall_banner]> {
- if <def[Value].as_item||null> == null {
- foreach next
}
- yaml set "<def[Value]>.current:1" id:prices
- yaml set "<def[Value]>.min:0" id:prices
- yaml set "<def[Value]>.max:2" id:prices
}
- yaml savefile:/prices.yml id:prices
- announce to_console "<&a>Generated new Price list!"
}
SetPrice_Command:
type: command
debug: false
name: setprice
usage: /setprice (item)
description: Set the price of the item specified, or item in hand.
permission: prices.sets
tab complete:
- if <yaml.list.contains[prices].not> queue clear
- choose <context.args.size>:
- case 0:
- determine <yaml[prices].list_keys[]>
- case 1:
- determine <yaml[prices].list_keys[].filter[starts_with[<context.args.last]>]>
script:
- if <yaml.list.contains[prices].not> {
- narrate "<&c>Prices are not loaded!"
- queue clear
}
- if <context.args.size> == 1 {
- define Item <player.item_in_hand.material.name>
- if <def[Item]> == air {
- narrate "<&c>Cannot set a price on air!"
- queue clear
}
- define Cost <context.args.get[1].as_decimal||null>
- if <def[Cost]> == null {
- narrate "<&c>Cost must be a number!"
- queue clear
}
- yaml set <def[Item]>:<def[Cost]> id:prices
- yaml savefile:/prices.yml id:prices
}
else if <context.args.size> == 2 {
- define Item <context.args.get[1].as_item||null>
- if <def[Item]> == null {
- narrate "<&c>That's not a real item!"
- queue clear
}
- define Item <def[Item].material.name>
- if <def[Item]> == air {
- narrate "<&c>Cannot set a price on air!"
- queue clear
}
- define Cost <context.args.get[2].as_decimal||null>
- if <def[Cost]> == null {
- narrate "<&c>Cost must be a number!"
- queue clear
}
- yaml set <def[Item].material.name>:<def[Cost]> id:prices
- yaml savefile:/prices.yml id:prices
}
else {
- narrate "<&6>Proper Syntax is:"
- narrate "<&6>/setprice cost (e.g. /setprice 5) to set price of item in hand."
- narrate "<&6>/setprice item cost (e.g. /setprice stone 5) to set the price of the item specified."
}
GetPrice Command:
type: command
name: getprice
usage: /getprice
description: Get the price of the item specified, or item in hand.
permission: prices.get
tab complete:
- if <yaml.list.contains[prices].not> queue clear
- choose <context.args.size>:
- case 0:
- determine <yaml[prices].list_keys[]>
- case 1:
- determine <yaml[prices].list_keys[].filter[starts_with[<context.args.last]>]>
script:
- if <yaml.list.contains[prices].not> {
- narrate "<&c>Prices are not loaded!"
- queue clear
}
- if <context.args.size> == 0 {
- define Item <player.item_in_hand.material.name>
- if <def[Item]> == air {
- narrate "<&c>Air does not have a price!"
- queue clear
}
- narrate "<&6>The price of <&f><def[Item].to_titlecase> <&6>is <&f><yaml[prices].read[<def[Item]>.current]><&6>."
}
else if <context.args.size> == 1 {
- define Item <context.args.get[1].as_item||null>
- if <def[Item]> == null {
- narrate "<&c>That's not a real item!"
- queue clear
}
- define Item <def[Item].material.name>
- if <def[Item]> == air {
- narrate "<&c>Air does not have a price!"
- queue clear
}
- narrate "<&6>The price of <&f><def[Item].to_titlecase> <&6>is <&f><yaml[prices].read[<def[Item]>.current]><&6>."
}