-
-
Notifications
You must be signed in to change notification settings - Fork 390
/
Copy pathExprCaughtErrors.java
59 lines (49 loc) · 1.62 KB
/
ExprCaughtErrors.java
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.expressions;
import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
@Name("Last Caught Errors")
@Description("Gets the last caught runtime errors from a 'catch runtime errors' section.")
@Example("""
catch runtime errors:
set worldborder center of {_border} to location(0, 0, NaN value)
if last caught runtime errors contains "Your location can't have a NaN value as one of its components":
set worldborder center of {_border} to location(0, 0, 0)
""")
@Since("INSERT VERSION")
public class ExprCaughtErrors extends SimpleExpression<String> {
static {
Skript.registerExpression(ExprCaughtErrors.class, String.class, ExpressionType.SIMPLE,
"last caught [run[ ]time] errors");
}
public static String[] lastErrors;
@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}
@Override
protected String @Nullable [] get(Event event) {
return lastErrors;
}
@Override
public boolean isSingle() {
return false;
}
@Override
public Class<? extends String> getReturnType() {
return String.class;
}
@Override
public String toString(@Nullable Event event, boolean debug) {
return "last caught runtime errors";
}
}