-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathworldedit.sk
152 lines (131 loc) · 5.52 KB
/
worldedit.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
options:
# the item used for selecting positions
skwe-wand: golden axe named "&6WorldEdit Wand"
# the permission used for all skwe related commands
permission: skwe.use
permission-message: &cPermission denied!
# code
function fillArea(p: player, loc1: location, loc2: location, blocks: text):
set {_x} to -1 if x coord of {_loc1} > x coord of {_loc2} else 1
set {_y} to -1 if y coord of {_loc1} > y coord of {_loc2} else 1
set {_z} to -1 if z coord of {_loc1} > z coord of {_loc2} else 1
set {_base} to {_loc1}
set {_u} to uuid of {_p}
set {_prior} to now
# multiblocks with percentages
if {_blocks} contains "%%":
set {_percentages} to true
loop {_blocks} split by ",":
set {_args::*} to loop-value split by "%%"
set {_block} to {_args::2} parsed as item
if {_block} is set:
set {_chance} to {_args::1} parsed as int
if {_chance} is set:
add {_block} to {_elements::*}
set {_chance::%{_block}%} to {_chance}
add {_chance} to {_total}
else:
send "&cInvalid percentage format" to {_p}
else:
send "&cOne or more of your block types were invalid" to {_p}
stop
if {_total} != 100:
send "&cYour chances must add up to 100%%" to {_p}
stop
# multiblocks
else if {_blocks} contains ",":
set {_list} to true
loop {_blocks} split by ",":
set {_block} to loop-value parsed as item
if {_block} is set:
add loop-value parsed as item to {_elements::*}
else:
send "&cOne or more of your block types were invalid" to {_p}
# single block
else:
set {_block} to {_blocks} parsed as item
if {_block} is not set:
send "&cBlock type invalid" to {_p}
stop
loop abs(x coord of {_loc1} - x coord of {_loc2}) + 1 times:
loop abs(z coord of {_loc1} - z coord of {_loc2}) + 1 times:
loop abs(y coord of {_loc1} - y coord of {_loc2}) + 1 times:
add 1 to {_placed}
set {undo::%{_u}%::%{_loc1}%} to "%block at {_loc1}%"
# multiblocks with percentages
if {_percentages} is set:
delete {_total}
set {_n} to random integer between 1 and 100
loop {_elements::*}:
if {_n} is between ({_total} + 1) and ({_total} + {_chance::%loop-value-4%}):
set block at {_loc1} to loop-value-4
exit 1 loop
add {_chance::%loop-value-4%} to {_total}
# multiblocks
else if {_list} is set:
set {_block} to random element out of {_elements::*}
set block at {_loc1} to {_block}
# single block
else:
set block at {_loc1} to {_block}
add {_y} to y coord of {_loc1}
add {_z} to z coord of {_loc1}
set y coord of {_loc1} to y coord of {_base}
add {_x} to x coord of {_loc1}
set z coord of {_loc1} to z coord of {_base}
send formatted "&d%{_placed}% blocks set in %difference between now and {_prior}%" to {_p}
command //undo:
permission: {@permission}
permission message: {@permission-message}
trigger:
if {undo::%player's uuid%::*} is set:
loop {undo::%player's uuid%::*}:
set {_args::*} to loop-index split by ":"
set {_world} to {_args::1}
set {_coords::*} to {_args::2} split by ","
set {_loc} to location at ({_coords::1} parsed as num), ({_coords::2} parsed as num), ({_coords::3} parsed as num) in {_world}
set block at {_loc} to loop-value parsed as item
send "&dYou have undone your last edit"
delete {undo::%player's uuid%::*}
else:
send "&cYou do not have any edits to undo!"
command //set [<text>]:
permission: {@permission}
permission message: {@permission-message}
trigger:
# reusability
set {_one} to metadata "skwe-pos-one" of player
set {_two} to metadata "skwe-pos-two" of player
if {_one} is set:
if {_two} is set:
fillArea(player, {_one}, {_two}, arg-1)
else:
send formatted "&cYour second skwe position is not set!"
else:
send formatted "&cYour first skwe position is not set!"
command //wand:
permission: {@permission}
permission message: {@permission-message}
trigger:
give player {@skwe-wand}
command //cut:
trigger:
execute player command "//set air"
on right click:
event-block is set
if player's tool = {@skwe-wand}:
if player has permission "{@permission}":
cancel event
set metadata "skwe-pos-one" of player to location of event-block
send formatted "&dPosition one set to %location of event-block%"
else:
send "{@permission-message}"
on left click:
event-block is set
if player's tool = {@skwe-wand}:
if player has permission "{@permission}":
cancel event
set metadata "skwe-pos-two" of player to location of event-block
send formatted "&dPosition two set to %location of event-block%"
else:
send "{@permission-message}"