A bracket handler is used to resolve ZenTokens inside <tokens>.
In order to do that, ZS will add all tokens inside the brackets to a list and go through all registered bracket handlers to find one that does not return null.
The annotated class simply need to implement IBracketHandler.

CraftTweaker Test Project Bracket Handler

java
Copy
@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));
        }

    }

}

What classes can be annotated || Additional Info

Link to what-classes-can-be-annotated--additional-info

  • You can annotate all Java Classes that are an instance of IBracketHandler.
  • You can give the annotation a priority value (e.g. priority = 100). The higher the prio the earlier that specific bracket handler is checked: CrT Bracket Handlers normally have a priority of 100.
  • After declaring a class a ZenBracketHandler, you still need to register it. It is recommended that you use @ZenRegister for that.
  • If your bracket Handler cannot resolve the brackets or is not meant to resolve the bracket, you should return null