Improve the annotated command method code and add more supported annotations

This commit is contained in:
Alexander Söderberg 2020-09-18 21:30:00 +02:00
parent 1e58ca3f13
commit 3f852d068e
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
15 changed files with 392 additions and 59 deletions

View file

@ -24,6 +24,7 @@
package com.intellectualsites.commands;
import com.intellectualsites.commands.arguments.CommandArgument;
import com.intellectualsites.commands.arguments.StaticArgument;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginIdentifiableCommand;
@ -32,17 +33,20 @@ import org.bukkit.plugin.Plugin;
import javax.annotation.Nonnull;
import java.util.List;
final class BukkitCommand<C>
extends org.bukkit.command.Command implements PluginIdentifiableCommand {
final class BukkitCommand<C> extends org.bukkit.command.Command implements PluginIdentifiableCommand {
private final CommandArgument<C, ?> command;
private final BukkitCommandManager<C> bukkitCommandManager;
private final com.intellectualsites.commands.Command<C, BukkitCommandMeta> cloudCommand;
@SuppressWarnings("unchecked")
BukkitCommand(@Nonnull final com.intellectualsites.commands.Command<C, BukkitCommandMeta> cloudCommand,
@Nonnull final CommandArgument<C, ?> command,
@Nonnull final BukkitCommandManager<C> bukkitCommandManager) {
super(command.getName());
super(command.getName(),
cloudCommand.getCommandMeta().getOrDefault("description", ""),
"",
((StaticArgument<C>) command).getAlternativeAliases());
this.command = command;
this.bukkitCommandManager = bukkitCommandManager;
this.cloudCommand = cloudCommand;
@ -92,4 +96,9 @@ final class BukkitCommand<C>
return this.bukkitCommandManager.getOwningPlugin();
}
@Override
public String getPermission() {
return this.cloudCommand.getCommandPermission();
}
}