Check if a user has permission to see tab complete suggestions

This commit is contained in:
Teriuihi 2022-01-31 03:15:43 +01:00 committed by destro174
parent 4571d191fd
commit c1b32e12cc

View File

@ -64,7 +64,9 @@ public class PartyCommand implements SimpleCommand {
String[] args = invocation.arguments(); String[] args = invocation.arguments();
List<String> suggest = new ArrayList<>(); List<String> suggest = new ArrayList<>();
if (args.length == 0) { if (!invocation.source().hasPermission("party.use"))
return suggest;
else if (args.length == 0) {
subCommands.stream() subCommands.stream()
.filter(subCommand -> invocation.source().hasPermission(subCommand.getPermission())) .filter(subCommand -> invocation.source().hasPermission(subCommand.getPermission()))
.forEach(subCommand -> suggest.add(subCommand.getName())); .forEach(subCommand -> suggest.add(subCommand.getName()));
@ -105,7 +107,8 @@ public class PartyCommand implements SimpleCommand {
subCommands.stream() subCommands.stream()
.filter(subCommand -> source.hasPermission(subCommand.getPermission())) .filter(subCommand -> source.hasPermission(subCommand.getPermission()))
.forEach(subCommand -> stringBuilder.append(subCommand.getHelpMessage()).append("\n")); .forEach(subCommand -> stringBuilder.append(subCommand.getHelpMessage()).append("\n"));
stringBuilder.append(Config.PARTY_HELP_CHAT).append("\n"); if (source.hasPermission("command.chat.p"))
stringBuilder.append(Config.PARTY_HELP_CHAT).append("\n");
if (stringBuilder.length() != 0) if (stringBuilder.length() != 0)
stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), ""); stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), "");
@ -113,8 +116,4 @@ public class PartyCommand implements SimpleCommand {
Template.template("commands", Utility.parseMiniMessage(stringBuilder.toString())) Template.template("commands", Utility.parseMiniMessage(stringBuilder.toString()))
)); ));
} }
public List<SubCommand> getSubCommands() {
return subCommands;
}
} }