mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Add tab completion for /plot schematic
This commit is contained in:
parent
f6ff843cfb
commit
52065b8313
@ -40,15 +40,15 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
|||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
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.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
import java.util.stream.Collectors;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "schematic",
|
@CommandDeclaration(command = "schematic",
|
||||||
permission = "plots.schematic",
|
permission = "plots.schematic",
|
||||||
@ -271,4 +271,27 @@ public class SchematicCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@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.schematic.save")) {
|
||||||
|
completions.add("save");
|
||||||
|
}
|
||||||
|
if (Permissions.hasPermission(player, "plots.schematic.list")) {
|
||||||
|
completions.add("list");
|
||||||
|
}
|
||||||
|
if (Permissions.hasPermission(player, "plots.schematic.paste")) {
|
||||||
|
completions.add("paste");
|
||||||
|
}
|
||||||
|
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.schematic") && 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