-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeafFFA.sk
314 lines (288 loc) · 14.2 KB
/
LeafFFA.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
import:
org.bukkit.Bukkit
org.bukkit.Sound
org.bukkit.material.MaterialData
org.bukkit.event.block.BlockFromToEvent
fr.mrmicky.fastparticle.FastParticle
fr.mrmicky.fastparticle.ParticleType
org.bukkit.event.player.PlayerInteractEvent
org.bukkit.event.player.PlayerArmorStandManipulateEvent
options:
#do not touch this -_-
plugin-version: 2.5.0
function ffa_check_yaml(dir: text, value: text, set: text, type: text = "text"):
yaml value {_value} from "leaf.ffa.%{_dir}%" is not set:
if {_type} is "text":
set yaml value {_value} from "leaf.ffa.%{_dir}%" to {_set}
if {_type} is "number":
set yaml value {_value} from "leaf.ffa.%{_dir}%" to {_set} parsed as number
if {_type} is "boolean":
set yaml value {_value} from "leaf.ffa.%{_dir}%" to {_set} parsed as boolean
if {_type} is "list":
yaml list {_value} from "leaf.ffa.%{_dir}%" is not set
loop {_set} split at "||":
add loop-value to yaml list {_value} from "leaf.ffa.%{_dir}%"
#From https://forums.skunity.com/resources/mirrorutils.706/ by EWS
local expression replacer %texts% with %texts% in %text%:
return type: text
get:
set {_result} to expr-3
loop exprs-1:
add 1 to {_n}
replace all "%loop-value-1%" with ({_n}th element of exprs-2 ? "") in {_result}
return {_result}
command ffa [<text = help>] [<text>]:
executable by: players
trigger:
if arg-1 is "help":
send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
send "&a/ffa join &8(&7arena_name&8)"
send "&a/ffa autojoin"
send "&a/ffa leave"
send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
if player has permission "ffa.admin":
send "&e/ffa createArena &8(&7arena_name&8)"
send "&e/ffa setSpawn &8(&7arena_name&8)"
send "&e/ffa setInventory &8(&7arena_name&8)"
send "&e/ffa enableArena &8(&7arena_name&8)"
send "&e/ffa setLeave"
send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
stop
if arg-1 is "join":
if {-ffa::cache::player::%player%::state} is set:
stop
if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is "ready":
ffa_join(player, arg-2)
stop
if arg-1 is "createArena":
if player has permission "ffa.admin":
if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
send "&cThis arena is already created."
stop
set yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" to "created"
send "&aArena &b%arg-2%&a created."
save yaml "leaf.ffa.data"
if arg-1 is "setSpawn":
if player has permission "ffa.admin":
if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
set yaml value "Arenas.%arg-2%.Spawn" from "leaf.ffa.data" to location of player
send "&aSpawn location Set for arena &b%arg-2%."
save yaml "leaf.ffa.data"
else:
send "&eThere is no arena called like this."
if arg-1 is "setInventory":
if player has permission "ffa.admin":
if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
set {_int} to 0
loop 36 times:
if slot {_int} of player's inventory != air:
set yaml value "Arenas.%arg-2%.Inventory.%{_int}%" from "leaf.ffa.data" to slot {_int} of player's inventory
add 1 to {_int}
set yaml value "Arenas.%arg-2%.Inventory.Helmet" from "leaf.ffa.data" to player's helmet
set yaml value "Arenas.%arg-2%.Inventory.Chestplate" from "leaf.ffa.data" to player's chestplate
set yaml value "Arenas.%arg-2%.Inventory.Leggings" from "leaf.ffa.data" to player's legging
set yaml value "Arenas.%arg-2%.Inventory.Boots" from "leaf.ffa.data" to player's boots
send "&aInventory for arena &b%arg-2% &asaved."
save yaml "leaf.ffa.data"
else:
send "&eThere is no arena called like this."
if arg-1 is "enableArena":
if player has permission "ffa.admin":
if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
set yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" to "ready"
send "&aArena &b%arg-2% &aenabled."
save yaml "leaf.ffa.data"
else:
send "&eThere is no arena called like this."
if arg-1 is "setLeave":
if player has permission "ffa.admin":
set yaml value "Locations.Leave" from "leaf.ffa.data" to location of player
send "&aLeave location set."
save yaml "leaf.ffa.data"
on load:
loop all players:
if {-ffa::cache::player::%loop-player%::state} is set:
ffa_leave({_p})
delete {-ffa::cache::*}
loop currently loaded yaml files:
loop-value contains "leaf.ffa.config" or "leaf.ffa.playerdata"
unload yaml loop-value-1
loop "config" and "data":
load yaml "plugins/LeafFFA/%loop-value-1%.yml" as "leaf.ffa.%loop-value-1%"
ffa_check_yaml("config", "Settings.ChatFormat", "&a{kills} &8✦ &7{player} &8» &7{message}")
ffa_check_yaml("config", "Settings.PointsPerKill", "5", "number")
ffa_check_yaml("config", "Settings.LosePointsOnDeath", "3", "number")
ffa_check_yaml("config", "Settings.RemoveBlockDelay", "3 seconds")
ffa_check_yaml("config", "Scoreboard.Name", "&8︼︼ &eFFA &8︼︼")
ffa_check_yaml("config", "Scoreboard.Lines", "&7{now}||||&7➥ &fYour Status ⤵||||&8▪ &fKills: &a{Kills}||&8▪ &fPoints: &a{Points}||&8▪ &fDeaths: &a{Deaths}||||&7➥ &fServer Status ⤵||||&8╔ &e&nMode&r: {arena}||&8╚ &e&nOnline&r: {playerCount}||||&eplay.my-cool-server.net", "list")
ffa_check_yaml("config", "Messages.Join", "&7{player} &ejoined.")
ffa_check_yaml("config", "Messages.Leave", "&7{player} &eleft.")
ffa_check_yaml("config", "Messages.Death", "&c➜ {victim} &7died")
ffa_check_yaml("config", "Messages.Killed", "&c➜ {victim} &7was killed by {killer}")
loop "config" and "data":
save yaml "leaf.ffa.%loop-value-1%"
loop yaml nodes with keys "Arenas" from "leaf.ffa.data":
loop {FFA::cache::arena::%loop-value-1%::Blocks::*}:
set block at loop-value-2 to air
add 1 to {_int}
if {_int} = 20:
set {_int} to 0
wait a tick
add world of yaml value "Arenas.%loop-value-1%.Spawn" from "leaf.ffa.data" to {-ffa::cache::Worlds::*}
set {-ffa::cache::BlockDelay} to yaml value "Settings.RemoveBlockDelay" from "leaf.ffa.config" parsed as timespan
set {-ffa::cache::SB::*} to "&a", "&b", "&c", "&d", "&e", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9" and "&f"
send "&7&l--------------------------------------------" to console
send " " to console
send "&aLoading &ev.{@plugin-version}&a..." to console
broadcast "&aLeafFFA loaded!"
send " " to console
send "&7&l--------------------------------------------" to console
on unload:
send "&7&l--------------------------------------------" to console
send " " to console
send "&aDisabling &ev.{@plugin-version}&a..." to console
send "&ev.{@plugin-version} &adisabled!" to console
send " " to console
send "&7&l--------------------------------------------" to console
function ffa_stats(p: player, do: text, type: text = "check", amount: number = 1):
if yaml "leaf.ffa.playerdata.%uuid of {_p}%" is not loaded:
load yaml "plugins/LeafFFA/playerdata/%uuid of {_p}%.yml" as "leaf.ffa.playerdata.%uuid of {_p}%"
{_do} is "check":
loop "Points", "Kills" and "Deaths":
if yaml value "Stats.%loop-value-1%" from "leaf.ffa.playerdata.%uuid of {_p}%" is not set:
set yaml value "Stats.%loop-value-1%" from "leaf.ffa.playerdata.%uuid of {_p}%" to 0
{_do} is "add":
set yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" to yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" + {_amount}
{_do} is "remove":
set yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" to yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" - {_amount}
save yaml "leaf.ffa.playerdata.%uuid of {_p}%"
function ffa_play_sound(p: player, soundLegacy: string, soundNew: string):
if {-mb::cache::sounds::%{_soundLegacy}%} is not set:
if minecraft version contains "1.8":
set {-mb::cache::sounds::%{_soundLegacy}%} to Sound..{_soundLegacy}
else:
set {-mb::cache::sounds::%{_soundLegacy}%} to Sound..{_soundNew}
else:
{_p}.playSound(location of {_p}, {-mb::cache::sounds::%{_soundLegacy}%}, 1 and 1)
on quit:
if {-ffa::cache::player::%player%::state} is set:
ffa_leave(player)
on break:
if {-ffa::cache::player::%player%::state} is set:
if {FFA::cache::arena::%{-ffa::cache::player::%player%::state}%::Blocks::%location of event-block%} is set:
stop
cancel event
on place:
if {-ffa::cache::player::%player%::state} is set:
set {_w} to world of player
set {FFA::cache::arena::%{-ffa::cache::player::%player%::state}%::Blocks::%location of event-block%} to location of event-block
wait {-ffa::cache::BlockDelay}
set event-block to air
FastParticle.spawnParticle({_w}, ParticleType.FLAME, location of event-block and 1)
on PlayerArmorStandManipulateEvent:
if {-ffa::cache::player::%event.getPlayer()%::state} is set:
cancel event
on PlayerInteractEvent:
if {-ffa::cache::player::%event.getPlayer()%::state} is set:
if "%event.getAction()%" is "PHYSICAL":
cancel event
on chat:
if {-ffa::cache::player::%player%::state} is set:
set {_format} to replacer "{player}" and "{message}" with "%player%" and message in yaml value "Settings.ChatFormat" from "leaf.ffa.config"
loop "Points", "Kills" and "Deaths":
set {_int} to yaml value "Stats.%loop-value-1%" from "leaf.ffa.playerdata.%uuid of player%"
replace all "{%loop-value-1%}" with "%{_int}%" in {_format}
set chat format to {_format}
set chat recipients to {-ffa::cache::arena::%{-ffa::cache::player::%player%::state}%::players::*}
on drop:
if {-ffa::cache::player::%player%::state} is set:
cancel event
on hunger bar change:
if {-ffa::cache::player::%player%::state} is set:
set player's hunger to 20
function ffa_join(p: player, arena: text):
yaml value "Arenas.%{_arena}%.State" from "leaf.ffa.data" is "ready"
ffa_stats({_p}, "check")
ffa_clear_player({_p})
set {-ffa::cache::player::%{_p}%::state} to {_arena}
teleport {_p} to yaml value "Arenas.%{_arena}%.Spawn" from "leaf.ffa.data"
set {_int} to 0
loop 36 times:
yaml value "Arenas.%{_arena}%.Inventory.%{_int}%" from "leaf.ffa.data" is set:
set slot {_int} of {_p}'s inventory to yaml value "Arenas.%{_arena}%.Inventory.%{_int}%" from "leaf.ffa.data"
add 1 to {_int}
set {_p}'s helmet to yaml value "Arenas.%{_arena}%.Inventory.Helmet" from "leaf.ffa.data"
set {_p}'s chestplate to yaml value "Arenas.%{_arena}%.Inventory.Chestplate" from "leaf.ffa.data"
set {_p}'s legging to yaml value "Arenas.%{_arena}%.Inventory.Leggings" from "leaf.ffa.data"
set {_p}'s boots to yaml value "Arenas.%{_arena}%.Inventory.Boots" from "leaf.ffa.data"
ffa_createBoard({_p})
add {_p} to {-ffa::cache::arena::%{_arena}%::players::*}
send replacer "{player}" with {_p}'s display name in yaml value "Messages.Join" from "leaf.ffa.config" to {-ffa::cache::arena::%{-ffa::cache::player::%{_p}%::state}%::players::*}
function ffa_leave(p: player):
ffa_clear_player({_p})
send replacer "{player}" with {_p}'s display name in yaml value "Messages.Leave" from "leaf.ffa.config" to {-ffa::cache::arena::%{-ffa::cache::player::%{_p}%::state}%::players::*}
delete {-ffa::cache::player::%{_p}%::*}
teleport {_p} to yaml value "Locations.Leave" from "leaf.ffa.data"
unload yaml "leaf.ffa.playerdata.%uuid of {_p}%"
function ffa_show_blood(p: player):
set {_w} to world of {_p}
set {_loc} to location of {_p}
set {_material} to new MaterialData(Material.."REDSTONE_BLOCK")
FastParticle.spawnParticle({_w}, ParticleType.BLOCK_CRACK, {_loc}, 3 and {_material})
function ffa_player_death(p: player):
set {_killer} to "%metadata value ""FFA_KILLER"" of {_p}%" parsed as player
ffa_stats({_p}, "add", "Deaths")
ffa_stats({_p}, "remove", "Deaths", yaml value "Settings.LosePointsOnDeath" from "leaf.ffa.config")
if {_killer} is set:
ffa_stats({_killer}, "add", "Kills")
send replacer "{victim}" and "{killer}" with "%{_p}%" and "%{_killer}%" in yaml value "Messages.Killed" from "leaf.ffa.config" to {-ffa::cache::arena::%{-ffa::cache::player::%{_p}%::state}%::players::*}
else:
send replacer "{victim}" with "%{_p}%" in yaml value "Messages.Death" from "leaf.ffa.config" to {-ffa::cache::arena::%{-ffa::cache::player::%{_p}%::state}%::players::*}
teleport {_p} to yaml value "Arenas.%{-ffa::cache::player::%{_p}%::state}%.Spawn" from "leaf.ffa.data"
ffa_play_sound({_p}, "ANVIL_BREAK", "BLOCK_ANVIL_BREAK")
ffa_play_sound({_killer}, "LEVEL_UP", "ENTITY_PLAYER_LEVELUP")
on damage of player:
if {-ffa::cache::player::%victim%::state} is set:
ffa_show_blood(victim)
if attacker is player:
set metadata value "FFA_KILLER" of victim to attacker
if damage >= health of victim:
cancel event
ffa_player_death(victim)
function ffa_clear_player(p: player):
heal {_p}
extinguish {_p}
set {_p}'s food to 20
clear {_p}'s level
clear {_p}'s inventory
{_p}.setFlying(false)
{_p}.setAllowFlight(false)
set {_p}'s gamemode to survival
loop ...{_p}.getActivePotionEffects():
{_p}.removePotionEffect(loop-value-1.getType())
set velocity of {_p} to new vector 0, 0, 0
function ffa_createBoard(p: player):
create scoreboard for {_p}
set scoreboard title of {_p} to yaml value "Scoreboard.Name" from "leaf.ffa.config"
while {-ffa::cache::player::%{_p}%::state} is set:
set {_slot} to 1
set {_playerCount} to 0
loop all players:
if {-ffa::cache::player::%loop-player%::state} is {-ffa::cache::player::%{_p}%::state}:
add 1 to {_playerCount}
loop yaml list "Scoreboard.Lines" from "leaf.ffa.config":
set {_value} to "%loop-value-1%"
replace all "{now}" with "%now%" in {_value}
replace all "{playerCount}" with "%{_playerCount}%" in {_value}
replace all "{arena}" with "%{-ffa::cache::player::%{_p}%::state}%" in {_value}
loop "Points", "Kills" and "Deaths":
set {_int} to yaml value "Stats.%loop-value-2%" from "leaf.ffa.playerdata.%uuid of {_p}%"
replace all "{%loop-value-2%}" with "%{_int}%" in {_value}
set scoreboard line {_slot} of {_p} to colored "%{-ffa::cache::SB::%{_slot}%}%%{_value}%"
add 1 to {_slot}
wait a second
on BlockFromToEvent:
if "%event.getToBlock().getType()%" contains "cobblestone" or "obsidian":
if {-ffa::cache::Worlds::*} contains "%event.getToBlock().getWorld()%":
cancel event
#El Psy Kongroo