mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16: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.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
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.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
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 net.kyori.adventure.text.minimessage.Template;
|
||||||
import com.plotsquared.core.uuid.UUIDMapping;
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "grant",
|
@CommandDeclaration(command = "grant",
|
||||||
category = CommandCategory.CLAIMING,
|
category = CommandCategory.CLAIMING,
|
||||||
@ -139,10 +141,22 @@ public class Grant extends Command {
|
|||||||
sendUsage(player);
|
sendUsage(player);
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
}
|
}
|
||||||
@Override public Collection<Command> tab(final PlotPlayer player, String[] args, boolean space) {
|
@Override public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
|
||||||
return Stream.of("check", "add")
|
if (args.length == 1) {
|
||||||
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))
|
final List<String> completions = new LinkedList<>();
|
||||||
.map(value -> new Command(null, false, value, "plots.grant", RequiredType.NONE, null) {
|
if (Permissions.hasPermission(player, "plots.grant.add")) {
|
||||||
}).collect(Collectors.toList());
|
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