Interface IBracketParserRegistrationHandler
A bracket expression in ZenCode is defined as anything starting with a < character. It is up to the
BracketExpressionParser to parse the code and define what needs to be done.
This definition is slightly restricted in CraftTweaker to allow for easier parsing and better cooperation. Each
bracket parser has a name which uniquely identifies it in the context of a
loader. When a < sign is encountered, the
first set of tokens until a colon (:) is read. The tokens are used to create a string which forms the name of
the parser. The current loader and the name are then used to identify the parser to invoke, which is then handed the
rest of the bracket expression.
As an example, when an expression like <item:minecraft:dirt> is found, item is used to
build a string (namely, "item") which is then used to identify the "item" bracket parser for the current
loader. If a bracket is found, then it is invoked with the remaining token stream (simplifying, with
minecraft:dirt>). It is up to the bracket expression parser to then figure out what to do.
- Since:
- 9.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordHolds information relative to a dumper for a specific bracket expression. -
Method Summary
Modifier and TypeMethodDescription<T extends Enum<T>>
voidregisterEnumForBracket(String loader, net.minecraft.resources.ResourceLocation id, Class<T> enumClass) Registers the given enum class as a valid target for the built-inenumbracket parser.default voidregisterParserFor(String loader, String parserName, Method parser) Registers a bracket expression parser that targets the specified parser name when within the given loader.default voidregisterParserFor(String loader, String parserName, Method parser, IBracketParserRegistrationHandler.DumperData dumper) Registers a bracket expression parser that targets the specified parser name when within the given loader.default voidregisterParserFor(String loader, String parserName, Method parser, Method validator) Registers a bracket expression parser that targets the specified parser name when within the given loader.voidregisterParserFor(String loader, String parserName, Method parser, Method validator, IBracketParserRegistrationHandler.DumperData dumper) Registers a bracket expression parser that targets the specified parser name when within the given loader.default voidregisterParserFor(String loader, String parserName, BracketExpressionParser parser) Registers a bracket expression parser that targets the specified parser name when within the given loader.voidregisterParserFor(String loader, String parserName, BracketExpressionParser parser, IBracketParserRegistrationHandler.DumperData parserDumper) Registers a bracket expression parser that targets the specified parser name when within the given loader.
-
Method Details
-
registerParserFor
void registerParserFor(String loader, String parserName, BracketExpressionParser parser, IBracketParserRegistrationHandler.DumperData parserDumper) Registers a bracket expression parser that targets the specified parser name when within the given loader.Refer to the main class documentation for more information on bracket parsers.
- Parameters:
loader- A string representing the loader in which the bracket expression should be parsed by the parser being registered.parserName- The name of the bracket that identifies this parser.parser- ABracketExpressionParserinstance that is responsible for parsing the bracket and building the resulting expression.parserDumper- AIBracketParserRegistrationHandler.DumperDataholding information relative to expression dumping, if available;nullotherwise.- Since:
- 9.1.0
-
registerParserFor
Registers a bracket expression parser that targets the specified parser name when within the given loader.Refer to the main class documentation for more information on bracket parsers.
No
IBracketParserRegistrationHandler.DumperDatais provided in this case, thus disallowing any possibility of dumping valid expressions for this bracket.- Parameters:
loader- A string representing the loader in which the bracket expression should be parsed by the parser being registered.parserName- The name of the bracket that identifies this parser.parser- ABracketExpressionParserinstance that is responsible for parsing the bracket and building the resulting expression.- Since:
- 9.1.0
-
registerParserFor
void registerParserFor(String loader, String parserName, Method parser, Method validator, IBracketParserRegistrationHandler.DumperData dumper) Registers a bracket expression parser that targets the specified parser name when within the given loader.Refer to the main class documentation for more information on bracket parsers.
The
parserandvalidatormethods are used to build a defaultBracketExpressionParserinstance that does what is supposed to. Refer to the documentation for the parameters for more information relative to the restrictions imposed on the signature of these methods.- Parameters:
loader- A string representing the loader in which the bracket expression should be parsed by the parser being registered.parserName- The name of the bracket that identifies this parser.parser- TheMethodresponsible for resolution of the bracket parser. The method must be located in a class that is exposed to ZenCode, be public and static, and have a singleStringparameter as input. The return type should also be a subtype ofCommandStringDisplayable. The method will be called automatically by CraftTweaker with the entire token stream between the first colon and the last closing bracket (i.e. between the first:and the ending>) read and converted to a string. It is up to the method to parse the string. If a validator is provided, the validator will be invoked before this method.validator- TheMethodresponsible for verifying that the expression given to the bracket parser is correct. The method must be public and static, and have a single input parameter of typeString. The return type must beboolean. The method will be called by CraftTweaker with the entire token stream between the first colon and the last closing bracket (i.e. between the first:and the ending>) read and converted to a string. It is up to the validator to parse the string and returntrueorfalsedepending on the string's validity. If no validator is desired, this parameter can benull.dumper- AIBracketParserRegistrationHandler.DumperDataholding information relative to expression dumping, if available; ornullif not desired.- Since:
- 9.1.0
-
registerParserFor
default void registerParserFor(String loader, String parserName, Method parser, IBracketParserRegistrationHandler.DumperData dumper) Registers a bracket expression parser that targets the specified parser name when within the given loader.Refer to the main class documentation for more information on bracket parsers.
The
parsermethod is used to build a defaultBracketExpressionParserinstance that does what is supposed to. Refer to the documentation for the parameters for more information relative to the restrictions imposed on the signature of the method.The created expression parser will have no validator.
- Parameters:
loader- A string representing the loader in which the bracket expression should be parsed by the parser being registered.parserName- The name of the bracket that identifies this parser.parser- TheMethodresponsible for resolution of the bracket parser. The method must be located in a class that is exposed to ZenCode, be public and static, and have a singleStringparameter as input. The return type should also be a subtype ofCommandStringDisplayable. The method will be called automatically by CraftTweaker with the entire token stream between the first colon and the last closing bracket (i.e. between the first:and the ending>) read and converted to a string. It is up to the method to parse the string.dumper- AIBracketParserRegistrationHandler.DumperDataholding information relative to expression dumping, if available; ornullif not desired.- Since:
- 9.1.0
-
registerParserFor
Registers a bracket expression parser that targets the specified parser name when within the given loader.Refer to the main class documentation for more information on bracket parsers.
The
parserandvalidatormethods are used to build a defaultBracketExpressionParserinstance that does what is supposed to. Refer to the documentation for the parameters for more information relative to the restrictions imposed on the signature of these methods.The created expression parser will not allow dumping of its expressions.
- Parameters:
loader- A string representing the loader in which the bracket expression should be parsed by the parser being registered.parserName- The name of the bracket that identifies this parser.parser- TheMethodresponsible for resolution of the bracket parser. The method must be located in a class that is exposed to ZenCode, be public and static, and have a singleStringparameter as input. The return type should also be a subtype ofCommandStringDisplayable. The method will be called automatically by CraftTweaker with the entire token stream between the first colon and the last closing bracket (i.e. between the first:and the ending>) read and converted to a string. It is up to the method to parse the string. If a validator is provided, the validator will be invoked before this method.validator- TheMethodresponsible for verifying that the expression given to the bracket parser is correct. The method must be public and static, and have a single input parameter of typeString. The return type must beboolean. The method will be called by CraftTweaker with the entire token stream between the first colon and the last closing bracket (i.e. between the first:and the ending>) read and converted to a string. It is up to the validator to parse the string and returntrueorfalsedepending on the string's validity. If no validator is desired, this parameter can benull.- Since:
- 9.1.0
-
registerParserFor
Registers a bracket expression parser that targets the specified parser name when within the given loader.Refer to the main class documentation for more information on bracket parsers.
The
parsermethod is used to build a defaultBracketExpressionParserinstance that does what is supposed to. Refer to the documentation for the parameters for more information relative to the restrictions imposed on the signature of the method.The created expression parser will have no validator and no possibility of dumping valid expressions.
- Parameters:
loader- A string representing the loader in which the bracket expression should be parsed by the parser being registered.parserName- The name of the bracket that identifies this parser.parser- TheMethodresponsible for resolution of the bracket parser. The method must be located in a class that is exposed to ZenCode, be public and static, and have a singleStringparameter as input. The return type should also be a subtype ofCommandStringDisplayable. The method will be called automatically by CraftTweaker with the entire token stream between the first colon and the last closing bracket (i.e. between the first:and the ending>) read and converted to a string. It is up to the method to parse the string.- Since:
- 9.1.0
-
registerEnumForBracket
<T extends Enum<T>> void registerEnumForBracket(String loader, net.minecraft.resources.ResourceLocation id, Class<T> enumClass) Registers the given enum class as a valid target for the built-inenumbracket parser.The enumeration will then be accessible through a bracket structured like the following:
<constant:id:constant>, where id represents the ID used to register the enumeration and constant the name of the constant that should be accessed.- Type Parameters:
T- The type of the enumeration that is being registered.- Parameters:
loader- A string representing the loader in which the enum should be available.id- AResourceLocationthat uniquely identifies the enumeration class.enumClass- The actual enum class.- Since:
- 9.1.0
-