Add asynchronous tab completion to the paper module

This commit is contained in:
Alexander Söderberg 2020-09-20 19:49:25 +02:00
parent 9d5f007e37
commit 6f0dba0bf0
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
14 changed files with 203 additions and 21 deletions

View file

@ -88,6 +88,12 @@ public final class BukkitTest extends JavaPlugin {
getLogger().warning("Failed to initialize Brigadier support: " + e.getMessage());
}
try {
((PaperCommandManager<CommandSender>) mgr).registerAsynchronousCompletions();
} catch (final Throwable e) {
getLogger().warning("Failed to register asynchronous command completions: " + e.getMessage());
}
final AnnotationParser<CommandSender> annotationParser
= new AnnotationParser<>(mgr, CommandSender.class, p ->
BukkitCommandMetaBuilder.builder().withDescription(p.get(StandardParameters.DESCRIPTION,
@ -180,7 +186,8 @@ public final class BukkitTest extends JavaPlugin {
@CommandMethod(value = "annotation|a <input> [number]", permission = "some.permission.node")
private void annotatedCommand(@Nonnull final Player player,
@Argument("input") @Completions("one,two,duck") @Nonnull final String input,
@Argument("number") @Range(min = "10", max = "100") final int number) {
@Argument(value = "number", defaultValue = "5") @Range(min = "10", max = "100")
final int number) {
player.sendMessage(ChatColor.GOLD + "Your input was: " + ChatColor.AQUA + input + ChatColor.GREEN + " (" + number + ")");
}