-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mines.sk
330 lines (314 loc) · 14.3 KB
/
mines.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
options:
version: 1.0.0
P: &8[&3Mines&8]&7
#
# MAIN COMMANDS
#
command /mines [<text>] [<text>]:
aliases: m, mine
permission: mines.use
permission message: "{@P} No permission."
trigger:
if arg-1 is not set:
send ""
send "{@P} Help Commands"
send "&c> &3/m info"
send ""
send "&c> &3/m list"
send "&c> &3/m wand"
send "&c> &3/m create [mine-name]"
send "&c> &3/m edit [mine-name]"
send "&c> &3/m reset [mine-name]"
send "&c> &3/m clear [mine-name]"
send "&c> &3/m lobby [mine-name]"
send ""
else if arg-1 is "info":
send ""
send "{@P} This script was created by skAdam (@Adxm##1343)."
send ""
send "&c> &7Version: &3{@version}"
send ""
else if arg-1 is "list":
set {_G} to chest inventory with 5 rows named "{@P} &8List"
set {_S} to 0
loop {mine::list::*}:
set slot {_S} of {_G} to name tag named "&3%loop-value%" with lore "&7Click to enter &3%loop-value%&7's properties gui." and "" and "&7Blocks: &3%{mine::%loop-value%::blocks::*}%" and "&7Reset Delay: &3%{mine::%loop-value%::resetdelay}%" and "&7Announce on Reset: &3%{mine::%loop-value%::broadcastOnReset}%"
add 1 to {_S}
open {_G} to player
set metadata "mines-gui" of player to "list"
else if arg-1 is "create":
if arg-2 is set:
if (amount of {mine::list::*}) < 40: # changing this will BREAK the code.
if {mine::setup::location-1} and {mine::setup::location-2} is set:
if {mine::list::*} does not contain arg-2:
add arg-2 to {mine::list::*}
set {mine::%arg-2%::loc-1} to {mine::setup::location-1}
set {mine::%arg-2%::loc-2} to {mine::setup::location-2}
set {mine::%arg-2%::setblockdelay} to 0
set {mine::%arg-2%::setblockdelay-display} to "None"
set {mine::%arg-2%::resetdelay} to 1
set {mine::%arg-2%::broadcastOnReset} to true
set {mine::%arg-2%::blocks::*} to "stone"
console command "mines reset %arg-2%"
send ""
send "{@P} Mine &3%arg-2%&7 created."
send "&c> &7The default block has been set to &3stone&7, to edit this and other properties, use &3/mines edit %arg-2%&7."
send ""
else:
send "{@P} This mine is already set."
else:
send "{@P} Mine location[s] are not set. Set them using the &3/mines wand&7."
else:
send "{@P} You have too many mines, please delete some. (This can be done easily with &3/mines list&7)"
else:
send "{@P} Enter a mine name."
else if arg-1 is "edit":
if arg-2 is set:
if {mine::%arg-2%::loc-1} is set:
if metadata "mines-inProcess" of player is not true:
set {_G} to chest inventory with 5 rows named "{@P} &3%arg-2%&8's properties."
set slot 4 of {_G} to barrier named "&c&lDelete Mine" with lore "&7&oDelete the mine."
set slot 10 of {_G} to diamond ore named "&c&lBlock List" with lore "&7&oChange mine's blocks."
set slot 12 of {_G} to oak sign named "&c&lAnnouncement" with lore "&7&oToggle announce on reset." and "&7Current Value: &3%{mine::%arg-2%::broadcastOnReset}%"
set slot 14 of {_G} to ender pearl named "&c&lLobby" with lore "&7&oSet mine's lobby location."
set slot 16 of {_G} to oak button named "&c&lReset" with lore "&7&oReset the mine."
set slot 28 of {_G} to painting named "&c&lHologram" with lore "&7&oSet the mine's hologram to your current location."
set slot 30 of {_G} to clock named "&c&lReset Delay" with lore "&7&oToggle how often the mine resets. [1, 5, 10 minutes]" and "&7Current Value: &3%{mine::%arg-2%::resetdelay}%"
set slot 32 of {_G} to clock named "&c&lBlock Set Delay" with lore "&7&oToggle the delay when setting blocks." and "&7&o[None = Instant, 1 = 1 tick per block]" and "&7Current Value: &3%{mine::%arg-2%::setblockdelay-display}%"
set slot 34 of {_G} to ice named "&c&lClear" with lore "&7&oClear the mine."
open {_G} to player
set metadata "mines-gui" of player to "properties"
set metadata "mines-mine" of player to arg-2
else:
send "{@P} Unable to enter the edit gui, are you in the process of another setup?"
send "&c> &7If this is a mistake, leave and rejoin."
else:
send "{@P} This mine is not set. 1 Create it by using &3/mines create %arg-2%&7."
else:
send "{@P} Enter a mine name."
else if arg-1 is "lobby":
if arg-2 is set:
if {mine::%arg-2%::loc-1} is set:
if {mine::%arg-2%::lobby} is set:
if player has permission "mines.lobby.%arg-2%":
teleport player to {mine::%arg-2%::lobby}
send "{@P} Going to &3%arg-2%&7's lobby."
else:
send "{@P} Invalid permissions!"
else:
send "{@P} The mine &3%arg-2%&7 does not have a lobby set. One can be set using &3/mines edit %arg-2%&7."
else:
send "{@P} This mine is not set. Create it by using &3/mines create %arg-2%&7."
else:
send "{@P} Enter a mine name."
else if arg-1 is "reset":
if arg-2 is set:
if {mine::%arg-2%::loc-1} is set:
if {mine::%arg-2%::broadcastOnReset} is true:
broadcast ""
broadcast "{@P} Mine &3%arg-2%&7 has been reset!"
broadcast ""
set {_D} to {mine::%arg-2%::setblockdelay}
if {mine::%arg-2%::lobby} is set:
loop all players:
if minesPlayerbetween(loop-player, {mine::%arg-2%::loc-1}, {mine::%arg-2%::loc-2}) is true:
player command "mines lobby %arg-2%"
loop all blocks within {mine::%arg-2%::loc-1} and {mine::%arg-2%::loc-2}:
if {_D} = 1:
wait 1 tick
set {_block} to random element out of {mine::%arg-2%::blocks::*}
set loop-block to {_block} parsed as material
else:
send "{@P} This mine is not set. Create it by using &3/mines create %arg-2%&7."
else:
send "{@P} Enter a mine name."
else if arg-1 is "clear":
if arg-2 is set:
if {mine::%arg-2%::loc-1} is set:
if {mine::%arg-2%::broadcastOnReset} is true:
broadcast ""
broadcast "{@P} Mine &3%arg-2%&7 has been cleared!"
broadcast ""
set {_D} to {mine::%arg-2%::setblockdelay}
if {mine::%arg-2%::lobby} is set:
loop all players:
if minesPlayerbetween(loop-player, {mine::%arg-2%::loc-1}, {mine::%arg-2%::loc-2}) is true:
player command "mines lobby %arg-2%"
loop all blocks within {mine::%arg-2%::loc-1} and {mine::%arg-2%::loc-2}:
if {_D} = 1:
wait 1 tick
set loop-block to air
else:
send "{@P} This mine is not set. Create it by using &3/mines create %arg-2%&7."
else:
send "{@P} Enter a mine name."
else if arg-1 is "wand":
give player stone axe named "{@P} &7Setup Wand"
send ""
send "{@P} You have been given your setup wand."
send "&c> &3Gamemode creative is required!"
send "&c> &7Right click to set location 1, and left click to set location 2."
send ""
on inventory click:
if metadata "mines-gui" of player is "properties":
clear metadata "mines-gui" of player
cancel event
if clicked slot is 4:
set {_M} to metadata "mines-mine" of player
delete {mine::%{_M}%::*}
remove {_M} from {mine::list::*}
close player's inventory
send ""
send "{@P} Mine &3%{_M}%&7 has been deleted."
send ""
clear metadata "mines-gui" of player
clear metadata "mines-mine" of player
if clicked slot is 10:
set {_M} to metadata "mines-mine" of player
set {_G} to chest inventory with 5 rows named "{@P} &3%{_M}%&8's blocks."
set slot 4 of {_G} to redstone block named "&c&lADD BLOCKS" with lore "&7&oThis will clear all the blocks and all blocks + the new ones will need to be added."
set {_S} to 9
loop {mine::%{_M}%::blocks::*}:
set slot {_S} of {_G} to loop-value parsed as material named "&3%loop-value%"
add 1 to {_S}
open {_G} to player
set metadata "mines-gui" of player to "blocks"
if clicked slot is 12:
set {_M} to metadata "mines-mine" of player
if {mine::%{_M}%::broadcastOnReset} is true:
delete {mine::%{_M}%::broadcastOnReset}
send "{@P} Mine &3%{_M}%&7 will no longer announce on reset."
else:
set {mine::%{_M}%::broadcastOnReset} to true
send "{@P} Mine &3%{_M}%&7 will now announce on reset."
player command "mines edit %{_M}%"
if clicked slot is 14:
set {_M} to metadata "mines-mine" of player
set {mine::%{_M}%::lobby} to player's location
send "{@P} Lobby location of mine &3%{_M}%&7 has been set."
send "&c> &7Players need the permission &3mines.lobby.%{_M}%&7 to warp to it."
if clicked slot is 16:
set {_M} to metadata "mines-mine" of player
console command "mines reset %{_M}%"
if clicked slot is 28:
set {_M} to metadata "mines-mine" of player
set {_L} to player's location
add 2 to y-loc of {_L}
send "{@P} Mine &3%{_M}%&7's hologram has been set to your location!"
if {mine::%{_M}%::holo} is set:
delete hologram {mine::%{_M}%::holo}
create a new hologram with lines "{@P} &3Information" and "&7Mine: &3&l%{_M}%", "&7Reset Delay: &3every &l%{mine::%{_M}%::resetdelay}%&3 minutes" and "&7Blocks: &3&l%{mine::%{_M}%::blocks::*}%" at {_L} and store in {mine::%{_M}%::holo}
if clicked slot is 30:
set {_M} to metadata "mines-mine" of player
if {mine::%{_M}%::resetdelay} is 1:
set {mine::%{_M}%::resetdelay} to 5
send "{@P} Reset delay for mine &3%{_M}%&7 has been set to 5 minutes."
else if {mine::%{_M}%::resetdelay} is 5:
set {mine::%{_M}%::resetdelay} to 10
send "{@P} Reset delay for mine &3%{_M}%&7 has been set to 10 minutes."
else if {mine::%{_M}%::resetdelay} is 10:
set {mine::%{_M}%::resetdelay} to 1
send "{@P} Reset delay for mine &3%{_M}%&7 has been set to 1 minutes."
player command "mines edit %{_M}%"
if clicked slot is 32:
set {_M} to metadata "mines-mine" of player
if {mine::%{_M}%::setblockdelay} is 0:
set {mine::%{_M}%::setblockdelay} to 1
set {mine::%{_M}%::setblockdelay-display} to 1
send "{@P} Mine &3%{_M}%&7's set block on reset delay is now 1 tick."
else if {mine::%{_M}%::setblockdelay} is 1:
set {mine::%{_M}%::setblockdelay} to 0
set {mine::%{_M}%::setblockdelay-display} to "None"
send "{@P} Mine &3%{_M}%&7's set block on reset delay is now 0 ticks (none)."
player command "mines edit %{_M}%"
if clicked slot is 34:
set {_M} to metadata "mines-mine" of player
console command "mine clear %{_M}%"
if metadata "mines-gui" of player is "blocks":
cancel event
if clicked slot is 4:
close player's inventory
set {_M} to metadata "mines-mine" of player
set metadata "mines-inProcess" of player to true
set metadata "mines-blockSetup" of player to true
send ""
send "{@P} Enter in chat what block types you want in mine &3%{_M}%&7."
send "&c> &7Don't use spaces to seperate them, use "";"" (eg ""stone;grass block"")"
send ""
if metadata "mines-gui" of player is "list":
cancel event
set {_N} to clicked slot's name
if {_N} is set:
replace all "&3" with "" in {_N}
player command "/mines edit %{_N}%"
clear metadata "mines-gui" of player
clear metadata "mines-properties" of player
every 1 minute:
loop {mine::list::*}:
if {mine::%loop-value%::resetdelay} is 1:
console command "mines reset %loop-value%"
every 5 minutes:
loop {mine::list::*}:
if {mine::%loop-value%::resetdelay} is 5:
console command "mines reset %loop-value%"
every 10 minutes:
loop {mine::list::*}:
if {mine::%loop-value%::resetdelay} is 10:
console command "mines reset %loop-value%"
on chat:
if metadata "mines-blockSetup" of player is true:
cancel event
set {_blocks} to message
set {_S::*} to split {_blocks} at ";"
if amount of {_S::*} < 35:
clear metadata "mines-blockSetup" of player
clear metadata "mines-inProcess" of player
set {_M} to metadata "mines-mine" of player
set {_blocks} to message
set {mine::%{_M}%::blocks::*} to split {_blocks} at ";"
console command "mines reset %{_M}%"
send ""
send "{@P} Mine &3%{_M}%&7's blocks have been set to &3%{mine::%{_M}%::blocks::*}%&7, and the mine has been reset."
send ""
clear metadata "mines-mine" of player
else:
send ""
send "{@P} Error, there is a maximum of 35 blocks allowed in each mine."
send ""
on join:
clear metadata "mines-inProcess" of player
clear metadata "mines-mine" of player
clear metadata "mines-blockSetup" of player
clear metadata "mines-gui" of player
#
# SETUPWAND: RIGHT CLICK
#
on right click with stone axe:
if name of player's held item is "{@P} &7Setup Wand":
if player has permission "mines.wand":
cancel event
set {mine::setup::location-1} to location of event-block
send "{@P} Location 1 set to &3%{mine::setup::location-1}%"
#
# SETUPWAND: LEFT CLICK
#
on break:
if held item is stone axe:
if name of player's held item is "{@P} &7Setup Wand":
if player has permission "mines.wand":
cancel event
set {mine::setup::location-2} to location of event-block
send "{@P} Location 2 set to &3%{mine::setup::location-2}%"
#
#
#
function minesPlayerbetweenCheck(a: number, b: number, c: number) :: boolean:
if {_a} is between {_b} and {_c}:
return true
else if {_a} is between {_c} and {_b}:
return true
function minesPlayerbetween(p: player, l1: location, l2: location) :: boolean:
if minesPlayerbetweenCheck(x coord of location of {_p}, x coord of {_l1}, x coord of {_l2}) = true:
if minesPlayerbetweenCheck(y coord of location of {_p}, y coord of {_l1}, y coord of {_l2}) = true:
if minesPlayerbetweenCheck(z coord of location of {_p}, z coord of {_l1}, z coord of {_l2}) = true:
return true