Add command proxies

This commit is contained in:
Alexander Söderberg 2020-09-25 02:20:04 +02:00
parent d3ed876df6
commit c980adac3b
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
6 changed files with 126 additions and 4 deletions

View file

@ -211,7 +211,16 @@ public final class AnnotationParser<C> {
} catch (final Exception e) {
throw new RuntimeException("Failed to construct command execution handler", e);
}
commands.add(builder.build());
final Command<C> builtCommand = builder.build();
commands.add(builtCommand);
/* Check if we need to construct a proxy */
if (method.isAnnotationPresent(ProxiedBy.class)) {
final String proxy = method.getAnnotation(ProxiedBy.class).value();
if (proxy.contains(" ")) {
throw new IllegalArgumentException("@ProxiedBy proxies may only contain single literals");
}
manager.command(manager.commandBuilder(proxy, builtCommand.getCommandMeta()).proxies(builtCommand).build());
}
}
return commands;
}