LiteCommands v3.7.0
What's Changed
- GH-440 Add Hacktoberfest 11 benner to README.md by @Rollczi in #440
- GH-441 Update README.md by @Rollczi in #441
- GH-427 Support async parse result. by @Rollczi in #435
- GH-442 Change default nativeMap of BiHashMap to ConcurrentHashMap by @OOP-778 in #443
- GH-445 Factories Unification by @SfenKer in #445
- GH-446 Hot fix offline player NPE. by @Rollczi in #447
Thanks @OOP-778 for the important bug fix ❤️
🟢 Add alias for @Context
annotation
@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:
@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()
@Override
protected ParseResult<User> parse(Invocation<CommandSender> invocation, Argument<User> context, String argument) {
return ParseResult.async(() -> userDatabase.getUser(argument));
}
🟢 See also same API for ContextResult
ContextResult.completableFuture()
ContextResult.async()
🔴 Removed wrapper API
🔴 Breaking changes (Internal API)
See more #435
Update dependencies
implementation("dev.rollczi:{artifact}:3.7.0")
<dependency>
<groupId>dev.rollczi</groupId>
<artifactId>{artifact}</artifactId>
<version>3.7.0</version>
</dependency>
{artifact}
with platform artifact
New Contributors
Full Changelog: v3.6.1...v3.7.0