Closed Rollczi closed 1 month ago
Resolve: #427 š¢ Add alias for @Context annotation
@Context
@Command(name = "hello") public class HelloCommand { @Execute void command(@Sender CommandSender sender, @Arg String name) { // ... } }
š¢ Add an option to create Annotation aliases like as @Sender You can implement your annotation:
@Sender
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @RequirementDefinition(type = RequirementDefinition.Type.CONTEXT) public @interface MySender { }
And use it in your commands:
@Execute void command(@MySender CommandSender sender, @Arg String name) { // ... }
š¢ Support completableFuture/async parse/context result:
public class UserArgumentResolver extends ArgumentResolver<CommandSender, User> { private final Pattern VALID_USER_PATTERN = Pattern.compile("^[a-zA-Z0-9_]{3,16}$"); private final UserService userService; public UserArgumentResolver(UserService userService) { this.userService = userService; } @Override protected ParseResult<User> parse(Invocation<CommandSender> invocation, Argument<User> context, String argument) { CompletableFuture<ParseResult<User>> userNotFound = userService.getUser(argument) .thenApply(user -> user != null ? ParseResult.success(user) : ParseResult.failure("User not found")); return ParseResult.completableFuture(userNotFound); } @Override public boolean match(Invocation<CommandSender> invocation, Argument<User> context, String argument) { return VALID_USER_PATTERN.matcher(argument).matches(); } }
š¢ when you call blocking methods you can use ParseResult.async()
ParseResult.async()
@Override protected ParseResult<User> parse(Invocation<CommandSender> invocation, Argument<User> context, String argument) { return ParseResult.async(() -> userDatabase.getUser(argument)); }
ā ļø When you return async/completableFuture result then you must also implement match method for correct suggestion validation
š¢ See also same API for ContextResult
ContextResult.completableFuture()
ContextResult.async()
š“ Rmoved wrapper API
incompatible:
AbstractCollectorArgumentResolver Meta.ARGUMENT_KEY Parser#canParse SchematicFastGenerator#isOptional SimpleArgument#constructor AnnotationHolder#getFormat Requirement#getWrapperFormat Argument#getWrapperFormat
BindRequirement.of(Supplier, WrapFormat) -> BindRequirement.of(Supplier, TypeToken) ContextRequirement.of(Supplier, WrapFormat) -> ContextRequirement.of(Supplier, TypeToken)
relocation:
litecommands.annotations.argument.collector -> [...]litecommands.annotations.argument.collection litecommands.requirement.BindRequirement -> litecommands.bind.BindRequirement litecommands.requirement.ContextRequirement -> litecommands.context.ContextRequirement CollectionArgument -> CollectionArgumentProfile JoinArgument -> JoinProfile FlagArgument -> FlagProfile
removed:
WrapperRegistry, Wrap, WrapFormat, ValueToWrap Wrapper, CompletableFutureWrapper, OptionaWrapper, ValueWrapper TypedArgumentResolver, TypedParser, TypedSuggester LiteCommandsBuilder#wrapper() RequirementProcessor AnnotationHolder
Resolve: #427 š¢ Add alias for
@Context
annotationš¢ Add an option to create Annotation aliases like as
@Sender
You can implement your annotation:And use it in your commands:
š¢ Support completableFuture/async parse/context result:
š¢ when you call blocking methods you can use
ParseResult.async()
ā ļø When you return async/completableFuture result then you must also implement match method for correct suggestion validation
š¢ See also same API for ContextResult
š“ Rmoved wrapper API
š“ Breaking changes (Internal API)
incompatible:
relocation:
removed: