-
-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy pathEffElytraBoostConsume.java
More file actions
59 lines (51 loc) · 1.8 KB
/
EffElytraBoostConsume.java
File metadata and controls
59 lines (51 loc) · 1.8 KB
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
package ch.njol.skript.effects;
import ch.njol.skript.Skript;
import ch.njol.skript.doc.*;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.EventRestrictedSyntax;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import ch.njol.util.coll.CollectionUtils;
import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
@Name("Consume Boosting Firework")
@Description("Prevent the firework used in an 'elytra boost' event to be consumed.")
@Example("""
on elytra boost:
if the used firework will be consumed:
prevent the used firework from being consume
""")
@Since("2.10")
public class EffElytraBoostConsume extends Effect implements EventRestrictedSyntax {
static {
if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) {
Skript.registerEffect(EffElytraBoostConsume.class,
"(prevent|disallow) [the] (boosting|used) firework from being consumed",
"allow [the] (boosting|used) firework to be consumed");
}
}
private boolean consume;
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
consume = matchedPattern == 1;
return true;
}
@Override
public Class<? extends Event>[] supportedEvents() {
return CollectionUtils.array(PlayerElytraBoostEvent.class);
}
@Override
protected void execute(Event event) {
if (!(event instanceof PlayerElytraBoostEvent boostEvent))
return;
boostEvent.setShouldConsume(consume);
}
@Override
public String toString(@Nullable Event event, boolean debug) {
if (consume)
return "allow the boosting firework to be consumed";
return "prevent the boosting firework from being consumed";
}
}