mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-05 06:32:17 -07:00
Check requirement before suggesting root nodes
Child nodes are handled by CommandDispatcher#parse checking requirements. Vanilla clients only send ServerboundCommandSuggestionPacket when encountering a command node with ASK_SERVER suggestions, however a modified client can send this packet whenever it wants.
This commit is contained in:
@@ -8,12 +8,19 @@
|
|||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.context.CommandContextBuilder;
|
import com.mojang.brigadier.context.CommandContextBuilder;
|
||||||
@@ -538,7 +539,7 @@
|
@@ -537,10 +538,14 @@
|
||||||
|
int i = 0;
|
||||||
for (final CommandNode<S> node : parent.getChildren()) {
|
for (final CommandNode<S> node : parent.getChildren()) {
|
||||||
CompletableFuture<Suggestions> future = Suggestions.empty();
|
CompletableFuture<Suggestions> future = Suggestions.empty();
|
||||||
|
+ // Paper start - Don't suggest if the requirement isn't met
|
||||||
|
+ if (parent != this.root || node.canUse(context.getSource())) {
|
||||||
try {
|
try {
|
||||||
- future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start));
|
- future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start));
|
||||||
+ if (node.canUse(parse.getContext().getSource())) future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start)); // CraftBukkit
|
+ future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, truncatedInputLowerCase, start)); // CraftBukkit
|
||||||
} catch (final CommandSyntaxException ignored) {
|
} catch (final CommandSyntaxException ignored) {
|
||||||
}
|
}
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Don't suggest if the requirement isn't met
|
||||||
futures[i++] = future;
|
futures[i++] = future;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user