Adds tab completion to the decrypt command

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

View File

@ -4,13 +4,15 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper; import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
import net.knarcraft.bookswithoutborders.utility.InventoryHelper; import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.BookMeta;
import java.io.File; 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.getBookFolder;
import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getSlash; import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getSlash;
@ -18,7 +20,7 @@ import static net.knarcraft.bookswithoutborders.BooksWithoutBordersSettings.getS
/** /**
* Command executor for the decrypt command * Command executor for the decrypt command
*/ */
public class CommandDecrypt implements CommandExecutor { public class CommandDecrypt implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -98,4 +100,15 @@ public class CommandDecrypt implements CommandExecutor {
return false; return false;
} }
} }
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
int argumentCount = args.length;
if (argumentCount == 1) {
List<String> info = new ArrayList<>();
info.add("<password>");
return info;
}
return new ArrayList<>();
}
} }