Fix plot set tab completions

This commit is contained in:
N0tMyFaultOG 2020-10-08 20:16:29 +02:00
parent e46b38b301
commit 6f0512c18c

View File

@ -45,6 +45,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Collections;
import java.util.LinkedList;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -213,15 +215,51 @@ public class Set extends SubCommand {
} }
@Override @Override
public Collection<Command> tab(final PlotPlayer player, final String[] args, public Collection<Command> tab(final PlotPlayer<?> player, String[] args, boolean space) {
final boolean space) {
if (args.length == 1) { if (args.length == 1) {
return Stream final List<String> completions = new LinkedList<>();
.of("biome", "alias", "home", "main", "floor", "air", "all", "border", "wall",
"outline", "middle") if (Permissions.hasPermission(player, "plots.set.biome")) {
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH))) completions.add("biome");
.map(value -> new Command(null, false, value, "", RequiredType.NONE, null) { }
}).collect(Collectors.toList()); 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<Command> 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) { } else if (args.length > 1) {
// Additional checks // Additional checks
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();