Add command meta & add new guided builder methods for components

This commit is contained in:
Alexander Söderberg 2020-09-10 13:03:26 +02:00
parent 0c0428e8d4
commit 90d37f1df8
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
21 changed files with 540 additions and 169 deletions

View file

@ -35,7 +35,7 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
final class BukkitPluginRegistrationHandler implements CommandRegistrationHandler {
final class BukkitPluginRegistrationHandler implements CommandRegistrationHandler<BukkitCommandMeta> {
private final Map<CommandComponent<?, ?>, org.bukkit.command.Command> registeredCommands = new HashMap<>();
@ -59,7 +59,7 @@ final class BukkitPluginRegistrationHandler implements CommandRegistrationHandle
}
@Override
public boolean registerCommand(@Nonnull final Command<?> command) {
public boolean registerCommand(@Nonnull final Command<?, BukkitCommandMeta> command) {
/* We only care about the root command component */
final CommandComponent<?, ?> commandComponent = command.getComponents().get(0);
if (this.registeredCommands.containsKey(commandComponent)) {
@ -71,6 +71,7 @@ final class BukkitPluginRegistrationHandler implements CommandRegistrationHandle
} else {
label = commandComponent.getName();
}
@SuppressWarnings("unchecked")
final BukkitCommand bukkitCommand = new BukkitCommand((CommandComponent<BukkitCommandSender, ?>) commandComponent,
this.bukkitCommandManager);
this.bukkitCommands.put(label, bukkitCommand);