From 610d798093b810d8367ccc42a9781559cc3499b4 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 8 Sep 2021 15:36:14 +0200 Subject: [PATCH] Adds tab completion to the copy command --- .../bookswithoutborders/command/CommandCopy.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java index f2be415..3d1d98b 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandCopy.java @@ -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 onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + int argumentCount = args.length; + if (argumentCount == 1) { + return TabCompletionHelper.getNumbers(1, 20); + } + return new ArrayList<>(); + } }