/
commands.sk
302 lines (286 loc) · 15 KB
/
commands.sk
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# ###################################################################
# Zabrid's Crate Maker
# Source Code
# Feel free to change anything below this point.
# Although, beware you might break something!
# If you make a change and think that it should be pushed to the official script
# make a pull request on the GitHub https://github.com/Zabrid/Zabrid-Crate-Maker
# ###################################################################
on tab complete of "/crates" and "/crate" and "/zcrates":
if player has permission "zcratemaker.help":
add "help" to {_tabs::*}
if player has permission "zcratemaker.create":
add "create" to {_tabs::*}
if player has permission "zcratemaker.delete":
add "delete" to {_tabs::*}
if player has permission "zcratemaker.edit":
add "edit" to {_tabs::*}
if player has permission "zcratemaker.list":
add "list" to {_tabs::*}
if player has permission "zcratemaker.giveall":
add "giveall" to {_tabs::*}
if player has permission "zcratemaker.give":
add "give" to {_tabs::*}
if player has permission "zcratemaker.additem":
add "additem" to {_tabs::*}
if player has permission "zcratemaker.setcrate":
add "setcrate" to {_tabs::*}
set tab completions for position 1 to {_tabs::*}
command /crates [<text>] [<text>] [<text>] [<text>] [<text>]:
aliases: /crate, /zcrates
trigger:
if arg 1 is not set:
if player does not have permission "zcratemaker.gui":
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
zcratemaker_gui_main(player)
else if arg 1 is "help":
if player does not have permission "zcratemaker.help":
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
send ""
send "&e&lCrate Maker"
send "&7 Author(s): &e{zabrid}##3433"
send ""
send "&6 -> &e/crate &7&o(zcratemaker.gui)"
send "&6 -> &e/crate list &7&o(zcratemaker.list)"
send "&6 -> &e/crate create <name> &7&o(zcratemaker.create)"
send "&6 -> &e/crate delete <name> &7&o(zcratemaker.delete)"
send "&6 -> &e/crate edit <name> &7&o(zcratemaker.edit)"
send "&6 -> &e/crate setcrate <name> &7&o(zcratemaker.setcrate)"
send "&6 -> &e/crate give <player> <crate> <type> <amt?1> &7&o(zcratemaker.give)"
send "&6 -> &e/crate giveall <crate> <type> <amt?1> &7&o(zcratemaker.giveall)"
send "&8 -> &e/crate additem <crate> <type=item,command> <chance> <command(s)> &7&o(zcratemaker.additem)"
send ""
else if arg 1 is "create":
if player has permission "zcratemaker.create":
set {_allow} to true
if sender is console:
set {_allow} to true
if {_allow} is not true:
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 1 is not set:
send "&cYou have not specified a name for the crate."
send "&6 -> &e/crate create <name>"
stop
if zcratemaker_createcrate(arg 2) is false:
send "&cThere is already a crate with that name."
stop
send ""
send "&a&lYOU HAVE CREATED A NEW CRATE"
send ""
send "&6 -> &eCreate Name: %arg 2%"
send ""
send formatted "&6 -> &eYou can edit the crate with &6/crate edit %arg 2% &7<suggest command:/crate edit %arg 2%>(Click Here)"
send formatted "&6 -> &eYou can also delete the crate with &6/cmd delete %arg 2% &7<suggest command:/crate delete %arg 2%>(Click Here)"
send ""
else if arg 1 is "delete":
if player has permission "zcratemaker.delete":
set {_allow} to true
if sender is console:
set {_allow} to true
if {_allow} is not true:
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou have not specified the name of the crate"
send "&6 -> &e/crate delete <name>"
stop
if {zcratemaker::crates::%arg 2%} is not set:
send "&cThere is no crate with that name."
stop
send "&cAre you sure you wish to delete this crate?"
send formatted "&cto confirm click <cmd:/crate d!elete-confirm$ %arg 2%>&fHere."
else if arg 1 is "d!elete-confirm$":
if player has permission "zcratemaker.delete":
set {_allow} to true
if sender is console:
set {_allow} to true
if {_allow} is not true:
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou have not specified the name of the crate"
send "&6 -> &e/crate delete <name>"
stop
if zcratemaker_deletecrate(arg 2) is false:
send "&cThere is no crate with that name."
stop
send "&6You have successfully delete the %arg 2% crate."
else if arg 1 is "edit":
if player does not have permission "zcratemaker.edit":
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou have not specified the name of the crate"
send "&6 -> &e/crate edit <name>"
stop
if {zcratemaker::crates::%arg 2%} is not set:
send "&cThere is no crate with that name."
stop
zcratemaker_gui_edit(player, arg 2)
else if arg 1 is "list":
if player does not have permission "zcratemaker.edit":
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if size of {zcratemaker::crates::*} is less than 1:
send "&cThere have been no crates created."
send formatted "&8 -> &eCreate a command with &6/crates create <suggest command:/crates create>&7(Click Here)"
stop
send ""
send "&6Full list of all created crates:"
loop {zcratemaker::crates::*}:
send formatted "&6 -> &e%loop-index% crate &8- <suggest command:/crates edit %loop-index%>&e(Edit)<suggest command:/crates delete %loop-index%> &4(Delete)"
send ""
else if arg 1 is "giveall":
if player has permission "zcratemaker.give":
set {_allow} to true
if sender is console:
set {_allow} to true
if {_allow} is not set:
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou must specify the crate to give to everyone"
send "&8 -> &e/crate giveall <crate> <type> <amt?1>"
stop
set {_list::*} to {zcratemaker::crates::*}
if {_list::*} does not contain arg 2:
send "&cThe crate you specified does not seem to exist."
stop
if arg 3 is not set:
send "&cYou must specify whether or not you're giving a virtual or a physical crate."
send "&8 -> &e/crate give <player> <crate> <type=v,p,virtual,physical> <amt?1>"
stop
if arg 3 is not "v" or "p" or "physical" or "virtual":
send "&cThe crate type you specified is invalid"
send "&8 -> &eValid Types: V, P, Virtual, Physical"
stop
set {_amt} to ( arg 5 ? 1 ) parsed as integer
if arg 3 is "p" or "physical":
set {_item} to zcratemaker_generatekey(arg 2)
loop all players:
add {_amt} of {_item} to loop-player's inventory
send "&aYou have given everyone %{_amt}% physical %arg 2% crate key(s)."
if arg 3 is "v" or "virtual":
loop all players:
zcratemaker_givekey(loop-player, arg 2, {_amt})
send "&aYou have given everyone %{_amt}% virtual %arg 2% crate key(s)."
else if arg 1 is "give":
if player has permission "zcratemaker.give":
set {_allow} to true
if sender is console:
set {_allow} to true
if {_allow} is not set:
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou must specify a player to give the crate to."
send "&8 -> &e/crate give <player> <crate> <type> <amt?1>"
stop
set {_p} to arg 2 parsed as offline player
if all players does not contain {_p}:
send "&cThe player you specified is not online."
stop
if arg 3 is not set:
send "&cYou must specify the crate to give to %{_p}%"
send "&8 -> &e/crate give <player> <crate> <type> <amt?1>"
stop
set {_list::*} to {zcratemaker::crates::*}
if {_list::*} does not contain arg 3:
send "&cThe crate you specified does not seem to exist."
stop
if arg 4 is not set:
send "&cYou must specify whether or not you're giving a virtual or a physical crate."
send "&8 -> &e/crate give <player> <crate> <type=v,p,virtual,physical> <amt?1>"
stop
if arg 4 is not "v" or "p" or "physical" or "virtual":
send "&cThe crate type you specified is invalid"
send "&8 -> &eValid Types: V, P, Virtual, Physical"
stop
set {_amt} to ( arg 5 ? 1 ) parsed as integer
if arg 4 is "p" or "physical":
set {_item} to zcratemaker_generatekey(arg 3)
add {_amt} of {_item} to {_p}'s inventory
send "&aYou have given %{_p}% %{_amt}% physical %arg 3% crate key(s)."
if arg 4 is "v" or "virtual":
zcratemaker_givekey(player, arg 3, {_amt})
send "&aYou have given %{_p}% %{_amt}% virtual %arg 3% crate key(s)."
else if arg 1 is "additem":
set {_chance} to arg 4 parsed as number
if player does not have permission "zcratemaker.additem":
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou must specify the crate to add your held item to."
send "&8 -> &e/crate additem <crate> <type=item,command> <chance> <command(s)>"
stop
if {zcratemaker::crates::%arg 2%} is not set:
send "&cThe crate you specified does not seem to exist."
stop
if player's tool is air:
send "&cYou're not holding an item in your hand."
stop
if arg 3 is not set:
send "&cYou must specify the type of the item you're adding."
send "&8 -> &eValid Types: &6Item, Command"
send "&8 -> &e/crate additem <crate> <type=item,command> <chance> <command(s)>"
stop
if arg 3 is not "item" or "command" or "i" or "c":
send "&cThe type you specified is not valid."
send "&8 -> &eValid Types: &6Item, Command"
stop
if arg 4 is not set:
send "&cYou must specify the chance you want a player to have of recieving this item."
send "&8 -> &e/crate additem <crate> <type=item,command> <chance> <command(s)>"
stop
if {_chance} is not set:
send "&cThe chance you specified is not a number."
stop
if arg 3 is "item" or "i":
add player's tool with nbt "{zcratemaker-chance:%{_chance}%,zcratemaker-id:""%random number between 0 and 10000000%""}" to {zcratemaker::crates::%arg 2%::items::*}
send "&aYou have added &2%player's tool%&a to the %arg 2% crate."
stop
if arg 3 is "command" or "c":
if arg 5 is not set:
send "&cYou must specify the commands. You can create seperate commands by seperating them with ""||""."
send "&7These commands will be run by console, you can use &6{p}&7 or &6{player}&7 to specify the player."
send "&8 -> &e/crate additem %arg 2% command <commands>"
stop
set {_commands::*} to arg 5 split by "||"
add player's tool with nbt "{zcratemaker-command:""%arg 5%"",zcratemaker-chance:%{_chance}%,zcratemaker-id:""%random number between 0 and 10000000%""}" to {zcratemaker::crates::%arg 2%::items::*}
send "&aYou have added &2%player's tool%&a to the %arg 2% crate."
send ""
send "&a&lCommands:"
loop {_commands::*}:
send "&a - &7%loop-value%"
send ""
stop
else if arg 1 is "setcrate":
if player does not have permission "zcratemaker.setcrate":
send zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("no-perms"))
stop
if arg 2 is not set:
send "&cYou must specify the crate you want to set the block to."
send "&7&o(( Use ""*"" to specify this as the main /crates menu ))"
send "&8 -> &e/crate setcrate <name>"
stop
if arg 2 is not "*":
if {zcratemaker::crates::%arg 2%} is not set:
send "&cThe crate you specified does not seem to exist."
stop
set {_tloc} to location of player's target block
set {_ploc} to player's location
if player's target block is not set:
send "&cThe block you're looking at is too far away."
stop
if distance between {_tloc} and {_ploc} is greater than 6:
send "&cThe block you're looking at is too far away."
stop
set {zcratemaker::cratelocations::%location of player's target block%} to arg 2
send "&aYou've set a &n%player's target block's type%&a at &n%location of player's target block%&a to a &n%arg 2% Crate&a"
else:
set {_message::*} to zcratemaker_formatbasicmessage("%sender%", zcratemaker_getlang("argument-not-recognized"))
replace all "{argument}" in {_message::*} with arg 1
send {_message::*}