From 2b6c271cc778c0d6876e113f5229097ad22884ad Mon Sep 17 00:00:00 2001 From: Frank van der Heijden Date: Sun, 13 Sep 2020 19:11:40 +0200 Subject: [PATCH] Add ability to check for command alias existence in api module --- .../com/velocitypowered/api/command/CommandManager.java | 8 ++++++++ .../proxy/command/VelocityCommandManager.java | 1 + 2 files changed, 9 insertions(+) diff --git a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java index b688adc63..68c3ed2c8 100644 --- a/api/src/main/java/com/velocitypowered/api/command/CommandManager.java +++ b/api/src/main/java/com/velocitypowered/api/command/CommandManager.java @@ -122,4 +122,12 @@ public interface CommandManager { * Can be completed exceptionally if an exception is thrown during execution. */ CompletableFuture 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); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java index cd5f034d7..b2d4e4f27 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -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;