diff --git a/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java b/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java index 1150c1cf1..2233e2a9b 100644 --- a/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java +++ b/api/src/main/java/com/velocitypowered/api/command/SimpleCommand.java @@ -16,5 +16,11 @@ public interface SimpleCommand extends InvocableCommand { + /** + * Returns the used alias to execute the command. + * + * @return the used command alias + */ + String alias(); } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java index 584ca092c..55b16c5a9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocitySimpleCommandInvocation.java @@ -15,11 +15,21 @@ final class VelocitySimpleCommandInvocation extends AbstractCommandInvocation context) { final String[] arguments = BrigadierUtils.getSplitArguments(context); - return new VelocitySimpleCommandInvocation(context.getSource(), arguments); + final String alias = BrigadierUtils.getAlias(context); + return new VelocitySimpleCommandInvocation(context.getSource(), alias, arguments); } } - VelocitySimpleCommandInvocation(final CommandSource source, final String[] arguments) { + private final String alias; + + VelocitySimpleCommandInvocation(final CommandSource source, final String alias, + final String[] arguments) { super(source, arguments); + this.alias = alias; + } + + @Override + public String alias() { + return this.alias; } }