Tab Completion

What is tab completion? 
Tab Completion is when you have a command that needs an argument and you can press tab to instantly add that argument. 

How do you set it up?
This is ONE way of doing this, there are surely other ways of doing this that might be better.


First off you need your class to extends TabCompleter. Next at the end of your command after everything is closed except for the class it self there you do the following.

@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
{



}

You may notice that this method looks similar to the onCommand() method but with a few changes.
Then in that method you wanna do the following.

List<String> arguments = Arrays.asList("args", "args2", "args3", "args4", "args5", "args6");
List<String> Flist = Lists.newArrayList();

In each string you need to put the argument to autocomplete, in order.
After that you want to check if the arguments are equal 1 and make a for loop.

if(args.length == 1)
{
	for(String s : arguments)
    {
		if(s.toLowerCase().startsWith(args[0].toLowerCase()))Flist.add(s);
    }
	return Flist;
}

Finally you need to return null. Your method should look similar to the following.

@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
{
	List<String> arguments = Arrays.asList("create", "remove", "list", "rents", "timecheck");
	List<String> list = Lists.newArrayList();

	if(args.length == 1)
    {
		for(String a : arguments)
        {
			if(a.toLowerCase().startsWith(args[0].toLowerCase()))list.add(a);
        }

		return list;
    }

	return null;
}    

In order for this to actually work you need to register it with your command on the onEnable() method, by doing the following.

getCommand("commandname").setTabCompleter(new commandClass());