Expose CommandMeta in CommandManager and add a ref to the plugin instance (#544)

This commit is contained in:
Frank van der Heijden
2021-10-31 21:23:35 +01:00
committed by GitHub
parent ac4b4a34ca
commit 922c001b59
4 changed files with 69 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ package com.velocitypowered.api.command;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Handles the registration and execution of commands.
@@ -74,6 +75,13 @@ public interface CommandManager {
*/
void unregister(String alias);
/**
* Retrieves the {@link CommandMeta} from the specified command alias, if registered.
* @param alias the command alias to lookup
* @return an {@link CommandMeta} of the alias
*/
@Nullable CommandMeta getCommandMeta(String alias);
/**
* Attempts to asynchronously execute a command from the given {@code cmdLine}.
*

View File

@@ -9,6 +9,7 @@ package com.velocitypowered.api.command;
import com.mojang.brigadier.tree.CommandNode;
import java.util.Collection;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Contains metadata for a {@link Command}.
@@ -32,6 +33,14 @@ public interface CommandMeta {
*/
Collection<CommandNode<CommandSource>> getHints();
/**
* Returns the plugin who registered the command.
* Note some {@link Command} registrations may not provide this information.
*
* @return the registering plugin
*/
@Nullable Object getPlugin();
/**
* Provides a fluent interface to create {@link CommandMeta}s.
*/
@@ -56,6 +65,14 @@ public interface CommandMeta {
*/
Builder hint(CommandNode<CommandSource> node);
/**
* Specifies the plugin who registers the {@link Command}.
*
* @param plugin the registering plugin
* @return this builder, for chaining
*/
Builder plugin(Object plugin);
/**
* Returns a newly-created {@link CommandMeta} based on the specified parameters.
*