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

Filter out subcommands in /velocity that users can't access.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-11-15 02:17:59 -05:00
Ursprung 2b0daa2122
Commit 66f47ecff1

Datei anzeigen

@ -36,7 +36,11 @@ public class VelocityCommand implements Command {
} }
private void usage(CommandSource source) { private void usage(CommandSource source) {
String commandText = "/velocity <" + String.join("|", subcommands.keySet()) + ">"; String availableCommands = subcommands.entrySet().stream()
.filter(e -> e.getValue().hasPermission(source, new String[0]))
.map(Map.Entry::getKey)
.collect(Collectors.joining("|"));
String commandText = "/velocity <" + availableCommands + ">";
source.sendMessage(TextComponent.of(commandText, TextColor.RED)); source.sendMessage(TextComponent.of(commandText, TextColor.RED));
} }
@ -64,8 +68,11 @@ public class VelocityCommand implements Command {
} }
if (currentArgs.length == 1) { if (currentArgs.length == 1) {
return subcommands.keySet().stream() return subcommands.entrySet().stream()
.filter(name -> name.regionMatches(true, 0, currentArgs[0], 0, currentArgs[0].length())) .filter(e -> e.getKey().regionMatches(true, 0, currentArgs[0], 0,
currentArgs[0].length()))
.filter(e -> e.getValue().hasPermission(source, new String[0]))
.map(Map.Entry::getKey)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }