-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathLitScriptName.java
49 lines (43 loc) · 1.48 KB
/
LitScriptName.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
package io.github.syst3ms.skriptparser.expressions;
import io.github.syst3ms.skriptparser.Parser;
import io.github.syst3ms.skriptparser.lang.Expression;
import io.github.syst3ms.skriptparser.lang.Literal;
import io.github.syst3ms.skriptparser.lang.TriggerContext;
import io.github.syst3ms.skriptparser.log.SkriptLogger;
import io.github.syst3ms.skriptparser.parsing.ParseContext;
import io.github.syst3ms.skriptparser.util.FileUtils;
import org.jetbrains.annotations.Nullable;
/**
* The name of the current executed script, without the extension.
*
* @name Script Name
* @pattern [the] [current] script[['s] name]
* @pattern name of [the] [current] script
* @since ALPHA
* @author Mwexim
*/
public class LitScriptName implements Literal<String> {
static {
Parser.getMainRegistration().addExpression(
LitScriptName.class,
String.class,
true,
"[the] [current] script[['s] name]",
"name of [the] [current] script"
);
}
private SkriptLogger logger;
@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) {
logger = parseContext.getLogger();
return true;
}
@Override
public String[] getValues() {
return new String[] {FileUtils.removeExtension(logger.getFileName())};
}
@Override
public String toString(@Nullable TriggerContext ctx, boolean debug) {
return "script name";
}
}