mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Fix plot grant tab completion
This commit is contained in:
parent
6f0512c18c
commit
02698b3a0e
@ -35,19 +35,21 @@ import com.plotsquared.core.player.PlayerMetaDataKeys;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.PlayerManager;
|
||||
import com.plotsquared.core.util.TabCompletions;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@CommandDeclaration(command = "grant",
|
||||
category = CommandCategory.CLAIMING,
|
||||
@ -139,10 +141,22 @@ public class Grant extends Command {
|
||||
sendUsage(player);
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
@Override public Collection<Command> tab(final PlotPlayer player, String[] args, boolean space) {
|
||||
return Stream.of("check", "add")
|
||||
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
.map(value -> new Command(null, false, value, "plots.grant", RequiredType.NONE, null) {
|
||||
}).collect(Collectors.toList());
|
||||
@Override public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
|
||||
if (args.length == 1) {
|
||||
final List<String> completions = new LinkedList<>();
|
||||
if (Permissions.hasPermission(player, "plots.grant.add")) {
|
||||
completions.add("add");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.grant.check")) {
|
||||
completions.add("check");
|
||||
}
|
||||
final List<Command> commands = completions.stream().filter(completion -> completion.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||
.map(completion -> new Command(null, true, completion, "", RequiredType.NONE, CommandCategory.ADMINISTRATION) {
|
||||
}).collect(Collectors.toCollection(LinkedList::new));
|
||||
if (Permissions.hasPermission(player, "plots.grant") && args[0].length() > 0) {
|
||||
commands.addAll(TabCompletions.completePlayers(args[0], Collections.emptyList()));
|
||||
}
|
||||
return commands;
|
||||
} return TabCompletions.completePlayers(String.join(",", args).trim(), Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user