Package dev.jorel.commandapi.arguments
Class ArgumentUtilities
java.lang.Object
dev.jorel.commandapi.arguments.ArgumentUtilities
-
Method Summary
Modifier and TypeMethodDescriptionstatic ParserLiteralReturns a newParserLiteral.static ParserArgument<String> readUntilWithoutEscapeCharacter(char terminator) Returns a newParserArgumentthat reads characters from the inputStringReaderuntil it reaches the given terminator character.static com.mojang.brigadier.MessagetranslatedMessage(String key) Turns a translation key into a BrigadierMessage.static com.mojang.brigadier.MessagetranslatedMessage(String key, Object... args) Turns a translation key into a BrigadierMessage.
-
Method Details
-
translatedMessage
Turns a translation key into a BrigadierMessage. These keys can be a default Minecraft Language Code or any translation loaded by a plugin.- Parameters:
key- The key for the message translation.- Returns:
- A Brigadier
Messagethat represents the given language key.
-
translatedMessage
Turns a translation key into a BrigadierMessage. These keys can be a default Minecraft Language Code or any translation loaded by a plugin.- Parameters:
key- The key for the message translation.args- Objects to insert into the string at the location of%smarkers in the resulting translated message.- Returns:
- A Brigadier
Messagethat represents the given language key.
-
literal
Returns a newParserLiteral. When the returned parser is invoked, it tries to read the givenliteralString from the inputStringReader. If theliteralis present, this parser succeeds and movesStringReader.getCursor()to the end of theliteral. Otherwise, this parser will fail and throw aCommandSyntaxExceptionwith typeBuiltInExceptionProvider.literalIncorrect().- Parameters:
literal- The exact String that is expected to be at the start of the inputStringReader.- Returns:
- A
ParserLiteralthat checks if theliteralString can be read from the inputStringReader.
-
readUntilWithoutEscapeCharacter
Returns a newParserArgumentthat reads characters from the inputStringReaderuntil it reaches the given terminator character. If the terminator character is not found, the entireStringReader.getRemaining()String will be read.Note - This is intended to work like
StringReader.readStringUntil(char)but with two differences: 1. This method does not treat\as a special character.StringReader.readStringUntil(char)allows the terminator character to be escaped by unescaped\. 2. This method does not throw aCommandSyntaxExceptionif the end of the string is reached without a terminator.StringReader.readStringUntil(char)will throwBuiltInExceptionProvider.readerExpectedEndOfQuote()if this happens.- Parameters:
terminator- The character to stop reading at.- Returns:
- A
ParserArgumentthat reads until it finds the given terminator. Note that the returned String will include the terminator at the end, unless the end of the inputStringReaderis reached without finding the terminator.
-