Merge pull request #43

*  Add a new caption system to allow for the configuration of…

*  Add caption support to all numerical types

* Add more standard pasres to the registry

* Add default messages for captions

*  Improve captions in core

* Add captions for Bukkit

*  Add FactoryDelegatingCaptionRegistry.java
This commit is contained in:
Alexander Söderberg 2020-10-12 18:13:23 +02:00 committed by GitHub
parent 378d57964f
commit 6ab1c8a2e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 1482 additions and 200 deletions

View file

@ -34,6 +34,7 @@ import cloud.commandframework.arguments.parser.ParserParameter;
import cloud.commandframework.arguments.parser.ParserParameters;
import cloud.commandframework.arguments.parser.StandardParameters;
import cloud.commandframework.arguments.preprocessor.RegexPreprocessor;
import cloud.commandframework.captions.Caption;
import cloud.commandframework.context.CommandContext;
import cloud.commandframework.execution.CommandExecutionHandler;
import cloud.commandframework.extra.confirmation.CommandConfirmationManager;
@ -97,7 +98,10 @@ public final class AnnotationParser<C> {
this.flagExtractor = new FlagExtractor(manager);
this.registerAnnotationMapper(CommandDescription.class, d ->
ParserParameters.single(StandardParameters.DESCRIPTION, d.value()));
this.registerPreprocessorMapper(Regex.class, annotation -> RegexPreprocessor.of(annotation.value()));
this.registerPreprocessorMapper(Regex.class, annotation -> RegexPreprocessor.of(
annotation.value(),
Caption.of(annotation.failureCaption())
));
}
/**

View file

@ -46,4 +46,12 @@ public @interface Regex {
*/
@NonNull String value();
/**
* Key for the caption used to generate the failure exception.
* Defaults to {@link cloud.commandframework.captions.StandardCaptionKeys#ARGUMENT_PARSE_FAILURE_REGEX}
*
* @return Failure caption key
*/
@NonNull String failureCaption() default "argument.parse.failure.regex";
}