diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java index 725d07667..3090ed3c5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -45,6 +45,8 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; +import java.util.Collections; +import java.util.LinkedList; import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -213,15 +215,51 @@ public class Set extends SubCommand { } @Override - public Collection tab(final PlotPlayer player, final String[] args, - final boolean space) { + public Collection tab(final PlotPlayer player, String[] args, boolean space) { if (args.length == 1) { - return Stream - .of("biome", "alias", "home", "main", "floor", "air", "all", "border", "wall", - "outline", "middle") - .filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) - .map(value -> new Command(null, false, value, "", RequiredType.NONE, null) { - }).collect(Collectors.toList()); + final List completions = new LinkedList<>(); + + if (Permissions.hasPermission(player, "plots.set.biome")) { + completions.add("biome"); + } + if (Permissions.hasPermission(player, "plots.set.alias")) { + completions.add("alias"); + } + if (Permissions.hasPermission(player, "plots.set.home")) { + completions.add("home"); + } + if (Permissions.hasPermission(player, "plots.set.main")) { + completions.add("main"); + } + if (Permissions.hasPermission(player, "plots.set.floor")) { + completions.add("floor"); + } + if (Permissions.hasPermission(player, "plots.set.air")) { + completions.add("air"); + } + if (Permissions.hasPermission(player, "plots.set.all")) { + completions.add("all"); + } + if (Permissions.hasPermission(player, "plots.set.border")) { + completions.add("border"); + } + if (Permissions.hasPermission(player, "plots.set.wall")) { + completions.add("wall"); + } + if (Permissions.hasPermission(player, "plots.set.outline")) { + completions.add("outline"); + } + if (Permissions.hasPermission(player, "plots.set.middle")) { + completions.add("middle"); + } + final List commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase())) + .map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.APPEARANCE) { + }).collect(Collectors.toCollection(LinkedList::new)); + + if (Permissions.hasPermission(player, "plots.set") && args[0].length() > 0) { + commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList())); + } + return commands; } else if (args.length > 1) { // Additional checks Plot plot = player.getCurrentPlot();