From bfeca40b1701c0aab15da66d9a325735ef1b9465 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 26 Nov 2019 14:07:55 -0500 Subject: [PATCH] Make sure we only tab-complete commands for which we have access to --- .../com/velocitypowered/proxy/command/VelocityCommand.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommand.java index a67582a0a..1c3b777c3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommand.java @@ -72,7 +72,10 @@ public class VelocityCommand implements Command { @Override public List suggest(CommandSource source, String @NonNull [] currentArgs) { if (currentArgs.length == 0) { - return ImmutableList.copyOf(subcommands.keySet()); + return subcommands.entrySet().stream() + .filter(e -> e.getValue().hasPermission(source, new String[0])) + .map(Map.Entry::getKey) + .collect(ImmutableList.toImmutableList()); } if (currentArgs.length == 1) { @@ -81,7 +84,7 @@ public class VelocityCommand implements Command { currentArgs[0].length())) .filter(e -> e.getValue().hasPermission(source, new String[0])) .map(Map.Entry::getKey) - .collect(Collectors.toList()); + .collect(ImmutableList.toImmutableList()); } Command command = subcommands.get(currentArgs[0].toLowerCase(Locale.US));