Add ability to check for command alias existence in api module

This commit is contained in:
Frank van der Heijden 2020-09-13 19:11:40 +02:00
parent 7650eedb7a
commit 2b6c271cc7
No known key found for this signature in database
GPG Key ID: 26DA56488D314D11
2 changed files with 9 additions and 0 deletions

View File

@ -122,4 +122,12 @@ public interface CommandManager {
* Can be completed exceptionally if an exception is thrown during execution.
*/
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine);
/**
* Returns whether the given alias is registered on this manager.
*
* @param alias the command alias to check
* @return {@code true} if the alias is registered
*/
boolean hasCommand(String alias);
}

View File

@ -227,6 +227,7 @@ public class VelocityCommandManager implements CommandManager {
* @param alias the command alias to check
* @return {@code true} if the alias is registered
*/
@Override
public boolean hasCommand(final String alias) {
Preconditions.checkNotNull(alias, "alias");
return dispatcher.getRoot().getChild(alias.toLowerCase(Locale.ENGLISH)) != null;