Date: 2016/07/25 10:06:15 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
########################################################################################################################################
#--------------------------------------------------------------------------------------------------------------------------------------#
#| ChestRestock Plugin Remake |#
#| Author: Kantorh |#
#| Author: Oruss7 |#
#| Version: 0.2 |#
#--------------------------------------------------------------------------------------------------------------------------------------#
########################################################################################################################################
#-----------------------------------------------------------------------------------------------------------------#
# NOTE: Please run init before use others commands #
#-----------------------------------------------------------------------------------------------------------------#
CRCommand:
Type: World
debug: false
Events:
on cr command:
- determine passively fulfilled
- if <context.args.get[1]> == 'null' {
- run CRHelp instantly player:<player>
} else if <context.args.get[1]> == 'help' {
- run CRHelp instantly player:<player>
} else if <context.args.get[1]> == 'create' {
- run CRCreate instantly player:<player> def:<context.args.get[2]>
} else if <context.args.get[1]> == 'remove' {
- run CRRemove instantly player:<player>
} else if <context.args.get[1]> == 'refresh' {
- run CRRefresh instantly player:<player>
} else if <context.args.get[1]> == 'check' {
- run CRCheck instantly player:<player>
} else if <context.args.get[1]> == 'update' {
- run CRUpdate instantly player:<player>
} else if <context.args.get[1]> == 'set' {
- run CRSet instantly player:<player>
} else if <context.args.get[1]> == 'init' {
- run CRInit instantly player:<player>
}
CRHelp:
type: task
debug: false
script:
- ^narrate target:<player> "<gold>------------------<<><<>Chest Restock<>><>>-------------------"
- ^narrate target:<player> "<blue>The command '<&b>/cr<blue>' is used for all ChestRestock functions."
- ^narrate target:<player> "<blue>The '<&b>/cr<blue>' command has the following sub-commands:"
- ^narrate target:<player> "<blue>1.<gold> /cr Help"
- ^narrate target:<player> "<&b> - Displays this help menu."
- ^narrate target:<player> "<blue>2.<gold> /cr Create (reset time)"
- ^narrate target:<player> "<&b> - Adds a chest and its current inventory to the database."
- ^narrate target:<player> "<blue>3.<gold> /cr Remove"
- ^narrate target:<player> "<&b> - Completely removes a chest from the database."
- ^narrate target:<player> "<blue>4.<gold> /cr Refresh"
- ^narrate target:<player> "<&b> - Forcibly restocks the chest."
- ^narrate target:<player> "<blue>5.<gold> /cr Check"
- ^narrate target:<player> "<&b> - Lists various settings for the targeted chest."
- ^narrate target:<player> "<blue>6.<gold> /cr Update"
- ^narrate target:<player> "<&b> - Updates the database's item list for the targeted chest."
- ^narrate target:<player> "<blue>7.<gold> /cr Set"
- ^narrate target:<player> "<&b> - Used to configure unique settings for individual chests."
- ^narrate target:<player> "<blue>7.<gold> /cr Init"
- ^narrate target:<player> "<&b> - Create files for first use."
- ^narrate target:<player> "<gold>----------------------<<><<>Help<>><>>------------------------"
CRCreate:
type: task
debug: false
definitions: resetTime
script:
- define chestlocation <player.location.cursor_on.simple>
- ^yaml load:chestdatabase.yml id:chestdatabase
- ^if <yaml[chestdatabase].list_keys[chests]> contains %chestlocation% {
- narrate "<gold>[ChestRestock] <red>This chest is already in the database!"
- narrate "<blue>To update the restock contents of this chest, simply place the desired items in the chest and type '<&2>/cr update<blue>'."
- ^yaml unload id:chestdatabase
- queue clear
}
- ^if <l@%chestlocation%.has_inventory> == 'true' {
- define contents "<l@%chestlocation%.inventory.list_contents>"
- ^yaml set chests.%chestlocation%:%contents% id:chestdatabase
- ^yaml savefile:chestdatabase.yml id:chestdatabase
- ^if %resetTime% != null {
- flag server chestrestock.%chestlocation%period:%resetTime%
}
- narrate "<gold>[ChestRestock] This chest will now restock its current inventory."
} else {
- narrate "<gold>[ChestRestock] <red>You must be targeting a valid container to use this command!"
}
- ^yaml unload id:chestdatabase
CRRemove:
type: task
debug: false
script:
- define chestlocation <player.location.cursor_on.simple>
- ^if <l@%chestlocation%.has_inventory> == 'true' {
- ^yaml load:chestdatabase.yml id:chestdatabase
- ^yaml set id:chestdatabase chests.%chestlocation%:!
- ^yaml savefile:chestdatabase.yml id:chestdatabase
- narrate "<gold>[ChestRestock] <red>This container has been removed from the database."
- ^yaml unload id:chestdatabase
} else {
- narrate "<red>You must be targeting a valid container to use this command!"
}
CRRefresh:
type: task
debug: false
script:
- ^define chestlocation <player.location.cursor_on.simple>
- ^if ( <player.has_flag[chestrestock.%chestlocation%]> && <player.flag[chestrestock.%chestlocation%]> ) {
- ^inventory clear 'd:<l@%chestlocation%.inventory>'
- queue clear
}
- ^inventory clear 'd:<l@%chestlocation%.inventory>'
- FOREACH <yaml[chestdatabase].read[chests.%chestlocation%]> {
- ^define item %value%
- ^give i@%item% "to:<l@%chestlocation%.inventory>"
}
- ^if <server.has_flag[chestrestock.%chestlocation%period]> {
- flag player "chestrestock.%chestlocation%" "duration:<server.flag[chestrestock.%chestlocation%period]>"
} else {
- flag player chestrestock.%chestlocation%
}
CRCheck:
type: task
debug: false
script:
- define chestlocation <player.location.cursor_on.simple>
- ^yaml load:chestdatabase.yml id:chestdatabase
- ^if <yaml[chestdatabase].list_keys[chests]> contains %chestlocation% {
- narrate "<gold>[ChestRestock] <red>This chest contains this items :"
- narrate "<yaml[chestdatabase].read[chests.%chestlocation%]>"
- queue clear
} else {
- narrate "<gold>[ChestRestock] <red>You must be targeting a valid container to use this command!"
}
CRUpdate:
type: task
debug: false
script:
- define chestlocation <player.location.cursor_on.simple>
- ^if <l@%chestlocation%.has_inventory> == 'true' {
- define contents "<l@%chestlocation%.inventory.list_contents>"
- ^note '<l@%chestlocation%.inventory>' 'as:<player.name><l@%chestlocation%.inventory>'
- ^yaml load:chestdatabase.yml id:chestdatabase
- ^yaml set chests.%chestlocation%:%contents% id:chestdatabase
- ^yaml savefile:chestdatabase.yml id:chestdatabase
- narrate "<red>Update succefully."
- ^yaml unload id:chestdatabase
} else {
- narrate "<gold>[ChestRestock] <red>You must be targeting a valid container to use this command!"
}
#---Command still in progress---#
# I will add more to this section as I complete it.
#CRSet:
# type: task
# script:
# - define chestlocation <player.location.cursor_on.simple>
CRInit:
type: task
debug: false
script:
- yaml create id:chestdatabase
- yaml savefile:chestdatabase.yml id:chestdatabase
- narrate "<gold>[ChestRestock] <red>ChestRestock files succefully created."
CROpenInv:
type: world
debug: false
events:
on player right clicks entity:
#- define chestlocation <player.location.cursor_on.simple>
- ^yaml load:chestdatabase.yml id:chestdatabase
- ^if <yaml[chestdatabase].list_keys[chests]> contains <context.location> {
# - RUN CRRefresh instantly player:<player>
# - narrate "blabla already take your item for today
- determine cancelled
}
- ^yaml unload id:chestdatabase
CRCloseInv:
type: world
debug: false
events:
on player closes chest:
- define chestlocation <player.location.cursor_on.simple>
- ^yaml load:chestdatabase.yml id:chestdatabase
- ^if <yaml[chestdatabase].list_keys[chests]> contains %chestlocation% {
- ^inventory clear 'd:<l@%chestlocation%.inventory>'
}
- ^yaml unload id:chestdatabase