-
-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy pathCondElytraBoostConsume.java
More file actions
58 lines (49 loc) · 1.8 KB
/
CondElytraBoostConsume.java
File metadata and controls
58 lines (49 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
package ch.njol.skript.conditions;
import ch.njol.skript.Skript;
import ch.njol.skript.doc.*;
import ch.njol.skript.lang.Condition;
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("Will Consume Boosting Firework")
@Description("Checks to see if the firework used in an 'elytra boost' event will be consumed.")
@Example("""
on elytra boost:
if the used firework will be consumed:
prevent the used firework from being consumed
""")
@Since("2.10")
public class CondElytraBoostConsume extends Condition implements EventRestrictedSyntax {
static {
if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent")) {
Skript.registerCondition(CondElytraBoostConsume.class,
"[the] (boosting|used) firework will be consumed",
"[the] (boosting|used) firework (will not|won't) be consumed");
}
}
private boolean checkConsume;
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
checkConsume = matchedPattern == 0;
return true;
}
@Override
public Class<? extends Event>[] supportedEvents() {
return CollectionUtils.array(PlayerElytraBoostEvent.class);
}
@Override
public boolean check(Event event) {
if (!(event instanceof PlayerElytraBoostEvent boostEvent))
return false;
return boostEvent.shouldConsume() == checkConsume;
}
@Override
public String toString(@Nullable Event event, boolean debug) {
return "the boosting firework will " + (checkConsume ? "" : "not") + " be consumed";
}
}