forked from CraftTweaker/CraftTweaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BracketWiki.java
45 lines (34 loc) · 1.38 KB
/
BracketWiki.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
package crafttweaker.tests.wiki;
import java.util.List;
import crafttweaker.annotations.BracketHandler;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.zenscript.IBracketHandler;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.util.ZenPosition;
@BracketHandler(priority = 34)
@ZenRegister
public class BracketWiki implements IBracketHandler{
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
if ((tokens.size() < 3)) return null;
if (!tokens.get(0).getValue().equalsIgnoreCase("devBracket")) return null;
if (!tokens.get(1).getValue().equals(":")) return null;
return new devSymbol(tokens);
}
private class devSymbol implements IZenSymbol {
private final String value;
public devSymbol(List<Token> tokens) {
StringBuilder sB = new StringBuilder();
tokens.stream().map(Token::getValue).forEach(sB::append);
this.value = sB.toString().replaceAll(":", " ");
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionString(position, "DevSymbol: ".concat(value));
}
}
}