Check permissions before providing suggestions (#430)

This commit is contained in:
David Mayr
2021-02-17 01:13:48 +01:00
committed by GitHub
parent 1a768bda9d
commit 648624d333
2 changed files with 56 additions and 0 deletions

View File

@@ -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);