From 620894f0b1355b33f46a298fc0695c315f72ff9b Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 8 Sep 2021 15:36:27 +0200 Subject: [PATCH] Adds tab completion to the decrypt command --- .../command/CommandDecrypt.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java index ccf46f7..d202128 100644 --- a/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java +++ b/src/main/java/net/knarcraft/bookswithoutborders/command/CommandDecrypt.java @@ -4,13 +4,15 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders; import net.knarcraft.bookswithoutborders.utility.EncryptionHelper; import net.knarcraft.bookswithoutborders.utility.InventoryHelper; 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.io.File; +import java.util.ArrayList; +import java.util.List; import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getBookFolder; import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getSlash; @@ -18,7 +20,7 @@ import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getS /** * Command executor for the decrypt command */ -public class CommandDecrypt implements CommandExecutor { +public class CommandDecrypt implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -98,4 +100,15 @@ public class CommandDecrypt implements CommandExecutor { return false; } } + + @Override + public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + int argumentCount = args.length; + if (argumentCount == 1) { + List info = new ArrayList<>(); + info.add(""); + return info; + } + return new ArrayList<>(); + } }