Adds tab completion to the copy command

This commit is contained in:
Kristian Knarvik 2021-09-08 15:36:14 +02:00
parent db3af1542b
commit 610d798093

View File

@ -4,19 +4,22 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.utility.EconomyHelper;
import net.knarcraft.bookswithoutborders.utility.InputCleaningHelper;
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
import net.knarcraft.bookswithoutborders.utility.TabCompletionHelper;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Command executor for the copy command
*/
public class CommandCopy implements CommandExecutor {
public class CommandCopy implements TabExecutor {
private final BooksWithoutBorders booksWithoutBorders = BooksWithoutBorders.getInstance();
@ -82,4 +85,12 @@ public class CommandCopy implements CommandExecutor {
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
int argumentCount = args.length;
if (argumentCount == 1) {
return TabCompletionHelper.getNumbers(1, 20);
}
return new ArrayList<>();
}
}