JCommands v6.0.0
Introduction to generics, new argument validation, new argument conversion, remove input value storage in arguments and more...
Changelog
JCommands now uses Javacord v3.8.0 (latest)
- Generics
- Arguments now have input and output generic type
- Argument validation and conversion uses generic to determine the type of the input and output
- Deprecations
- Classes and methods that have been marked as deprecated in the previous version are now removed completely
- Autocompletable interface is now deprecated, instead of there is an abstract AutocompletableInputArgument class that is an extension of InputArgument
- Optionality interface is now deprecated, InputArgument and its extensions can be marked as optional by default.
- The method to specify argument mismatch event in arguments now deprecated, it has been replaced with a new validation system
- ValueArgument is now deprecated, instead the new regex validation can be used on arguments with String input type to validate the input by a regex pattern
- Modifications
- ComboArgument is now an InputArgument
- Commands now can be age-restricted (NSFW)
- Inputs now does not get stored in the arguments (I know that this was not made any sense, and it also was buggy)
- The regex validation of command's and argument's name has been updated according to Discord docs
- StringArgument and NumberArgument are the only arguments that are autocompletable
- Converter now belongs to one argument not globally to every argument with matching input and output type, that means when the argument has different output type than input type, a converter has to specified in the argument directly to be able to convert the input to the output type.
- New argument validation
- InputArgument's input value can be validated with predicates
- Arguments with String input type can be validated by regex pattern with RegexPredicate validation
- StringLengthPredicate to validate length of Strings and NumberPredicate to validate numbers
As always, a detailed explanation of the features can be found on the wiki page.
Usage
The repository is now on Maven Central, so it is recommended to switch from JitPack.
Maven
<dependency>
<groupId>io.github.s3ns3iw00</groupId>
<artifactId>jcommands</artifactId>
<version>6.0.0</version>
</dependency>
Gradle
dependencies {
implementation 'io.github.s3ns3iw00.jcommands:6.0.0'
}
If you not familiar with these build tools, you can download the jar file below and use it as dependency in your project, but instead it is recommended to use a build tool.