Check permissions before providing suggestions (#430)
This commit is contained in:
@@ -46,6 +46,10 @@ public interface CommandNodeFactory<T extends Command> {
|
||||
},
|
||||
(context, builder) -> {
|
||||
String[] args = BrigadierUtils.getSplitArguments(context);
|
||||
if (!command.hasPermission(context.getSource(), args)) {
|
||||
return builder.buildFuture();
|
||||
}
|
||||
|
||||
return command.suggestAsync(context.getSource(), args).thenApply(values -> {
|
||||
for (String value : values) {
|
||||
builder.suggest(value);
|
||||
@@ -82,6 +86,9 @@ public interface CommandNodeFactory<T extends Command> {
|
||||
(context, builder) -> {
|
||||
I invocation = createInvocation(context);
|
||||
|
||||
if (!command.hasPermission(invocation)) {
|
||||
return builder.buildFuture();
|
||||
}
|
||||
return command.suggestAsync(invocation).thenApply(values -> {
|
||||
for (String value : values) {
|
||||
builder.suggest(value);
|
||||
|
Reference in New Issue
Block a user