package com.censoredsoftware.censoredlib.helper;

import com.google.common.collect.Lists;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;

import java.util.List;
import java.util.Set;

public abstract class WrappedCommand implements TabExecutor
{
	public WrappedCommand(CensoredJavaPlugin plugin, boolean tab)
	{
		for(String command : getCommands())
		{
			plugin.getCommand(command).setExecutor(this);
			if(tab) plugin.getCommand(command).setTabCompleter(this);
		}
	}

	public abstract Set<String> getCommands();

	public abstract boolean processCommand(CommandSender sender, Command command, final String[] args);

	public List<String> processTab(CommandSender sender, Command command, final String[] args)
	{
		return Lists.newArrayList();
	}

	@Override
	public List<String> onTabComplete(CommandSender sender, Command command, String label, final String[] args)
	{
		return processTab(sender, command, args);
	}

	@Override
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
	{
		return processCommand(sender, command, args);
	}
}

@@ -72,21 +72,173 @@
 mon.
-collect.Lists
+base.Function;%0Aimport com.google.common.collect.Collections2;%0Aimport com.google.common.collect.Lists;%0Aimport com.google.common.collect.Sets;%0Aimport org.bukkit.Bukkit
 ;%0Aim
@@ -347,24 +347,53 @@
 bExecutor;%0A%0A
+import java.util.Collection;%0A
 import java.
@@ -587,16 +587,20 @@
 tCommand
+Name
 s())%0A%09%09%7B
@@ -761,14 +761,431 @@
 mand
+Name
 s();%0A%0A
+%09public Set%3CString%3E getAliases()%0A%09%7B%0A%09%09Set%3CString%3E set = Sets.newHashSet();%0A%09%09for(Command command : getCommands())%0A%09%09%09set.addAll(command.getAliases());%0A%09%09return set;%0A%09%7D%0A%0A%09public Collection%3CCommand%3E getCommands()%0A%09%7B%0A%09%09return Collections2.transform(getCommandNames(), new Function%3CString, Command%3E()%0A%09%09%7B%0A%09%09%09@Override%0A%09%09%09public Command apply(String name)%0A%09%09%09%7B%0A%09%09%09%09return Bukkit.getPluginCommand(name);%0A%09%09%09%7D%0A%09%09%7D);%0A%09%7D%0A%0A
 %09pub
@@ -1742,10 +1742,9 @@
 gs);%0A%09%7D%0A
+
 %7D
-%0A

Update WrappedCommand.