Skip to content

Commit 01cb392

Browse files
committed
New line expression.
1 parent f4659db commit 01cb392

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/main/java/mx/kenzie/skript/compiler/SkriptLangSpec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ private SkriptLangSpec() {
168168
new SupplierSection(),
169169
new RunnableSection(),
170170
new ThreadExpression(),
171+
new NewLineExpression(),
171172
new ResultOfExpression(), // must try before property
172173
new PropertyExpression(),
173174
new SystemInputExpression(),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package mx.kenzie.skript.lang.syntax.generic;
2+
3+
import mx.kenzie.foundation.Type;
4+
import mx.kenzie.skript.api.syntax.SimpleExpression;
5+
import mx.kenzie.skript.compiler.CommonTypes;
6+
import mx.kenzie.skript.compiler.SkriptLangSpec;
7+
import mx.kenzie.skript.lang.element.StandardElements;
8+
import mx.kenzie.skript.lang.handler.StandardHandlers;
9+
10+
public class NewLineExpression extends SimpleExpression {
11+
12+
public NewLineExpression() {
13+
super(SkriptLangSpec.LIBRARY, StandardElements.EXPRESSION, "(new[ ]line|nl)");
14+
handlers.put(StandardHandlers.GET, findMethod(System.class, "lineSeparator"));
15+
}
16+
17+
@Override
18+
public Type getReturnType() {
19+
return CommonTypes.STRING;
20+
}
21+
22+
@Override
23+
public boolean allowAsInputFor(Type type) {
24+
return CommonTypes.STRING.equals(type) || CommonTypes.OBJECT.equals(type);
25+
}
26+
27+
}

src/test/resources/generic.bsk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function generic_expressions:
1010
assert {var} is "a"
1111
set {var} to (false ? "a" : "b")
1212
assert {var} is "b"
13+
assert newline is a string
1314

1415

1516
function test_system:

0 commit comments

Comments
 (0)