geforkt von Mirrors/Velocity
Add SimpleCommand.Invocation#alias function.
It seems like this ability is generally useful outside RawCommand, so let's add this to SimpleCommand too.
Dieser Commit ist enthalten in:
Ursprung
7dffa7ce33
Commit
1717d7f9b4
@ -16,5 +16,11 @@ public interface SimpleCommand extends InvocableCommand<SimpleCommand.Invocation
|
|||||||
*/
|
*/
|
||||||
interface Invocation extends CommandInvocation<String @NonNull []> {
|
interface Invocation extends CommandInvocation<String @NonNull []> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the used alias to execute the command.
|
||||||
|
*
|
||||||
|
* @return the used command alias
|
||||||
|
*/
|
||||||
|
String alias();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,21 @@ final class VelocitySimpleCommandInvocation extends AbstractCommandInvocation<St
|
|||||||
@Override
|
@Override
|
||||||
public SimpleCommand.Invocation create(final CommandContext<CommandSource> context) {
|
public SimpleCommand.Invocation create(final CommandContext<CommandSource> context) {
|
||||||
final String[] arguments = BrigadierUtils.getSplitArguments(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);
|
super(source, arguments);
|
||||||
|
this.alias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String alias() {
|
||||||
|
return this.alias;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren