2021-02-16 21:58:31 +01:00
|
|
|
package net.knarcraft.stargate.command;
|
|
|
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.command.TabCompleter;
|
2021-11-09 02:04:59 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2021-02-16 21:58:31 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2021-02-19 12:07:34 +01:00
|
|
|
/**
|
|
|
|
* This is the tab completer for the /stargate (/sg) command
|
|
|
|
*/
|
2021-02-16 21:58:31 +01:00
|
|
|
public class StarGateTabCompleter implements TabCompleter {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command,
|
2021-09-20 13:56:30 +02:00
|
|
|
@NotNull String s, @NotNull String[] args) {
|
2021-02-16 21:58:31 +01:00
|
|
|
List<String> commands = new ArrayList<>();
|
|
|
|
commands.add("about");
|
2021-11-09 02:04:59 +01:00
|
|
|
if (!(commandSender instanceof Player player) || player.hasPermission("stargate.admin.reload")) {
|
|
|
|
commands.add("reload");
|
|
|
|
}
|
|
|
|
if (!(commandSender instanceof Player player) || player.hasPermission("stargate.admin")) {
|
|
|
|
commands.add("config");
|
|
|
|
}
|
|
|
|
|
2021-09-20 13:56:30 +02:00
|
|
|
|
|
|
|
if (args.length == 1) {
|
|
|
|
return commands;
|
|
|
|
} else {
|
|
|
|
return new ArrayList<>();
|
|
|
|
}
|
2021-02-16 21:58:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|