3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Make sure we only tab-complete commands for which we have access to

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-11-26 14:07:55 -05:00
Ursprung e29e20b1e8
Commit bfeca40b17

Datei anzeigen

@ -72,7 +72,10 @@ public class VelocityCommand implements Command {
@Override @Override
public List<String> suggest(CommandSource source, String @NonNull [] currentArgs) { public List<String> suggest(CommandSource source, String @NonNull [] currentArgs) {
if (currentArgs.length == 0) { 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) { if (currentArgs.length == 1) {
@ -81,7 +84,7 @@ public class VelocityCommand implements Command {
currentArgs[0].length())) currentArgs[0].length()))
.filter(e -> e.getValue().hasPermission(source, new String[0])) .filter(e -> e.getValue().hasPermission(source, new String[0]))
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.collect(Collectors.toList()); .collect(ImmutableList.toImmutableList());
} }
Command command = subcommands.get(currentArgs[0].toLowerCase(Locale.US)); Command command = subcommands.get(currentArgs[0].toLowerCase(Locale.US));