package net.minecraft.command;

import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;

public class CommandServerKick extends CommandBase
{
	private static final String __OBFID = "CL_00000550";

	public String getCommandName()
	{
		return "kick";
	}

	public int getRequiredPermissionLevel()
	{
		return 3;
	}

	public String getCommandUsage(ICommandSender par1ICommandSender)
	{
		return "commands.kick.usage";
	}

	public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
	{
		if (par2ArrayOfStr.length > 0 && par2ArrayOfStr[0].length() > 1)
		{
			EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]);
			String s = "Kicked by an operator.";
			boolean flag = false;

			if (entityplayermp == null)
			{
				throw new PlayerNotFoundException();
			}
			else
			{
				if (par2ArrayOfStr.length >= 2)
				{
					s = func_147178_a(par1ICommandSender, par2ArrayOfStr, 1).getUnformattedText();
					flag = true;
				}

				entityplayermp.playerNetServerHandler.kickPlayerFromServer(s);

				if (flag)
				{
					notifyAdmins(par1ICommandSender, "commands.kick.success.reason", new Object[] {entityplayermp.getCommandSenderName(), s});
				}
				else
				{
					notifyAdmins(par1ICommandSender, "commands.kick.success", new Object[] {entityplayermp.getCommandSenderName()});
				}
			}
		}
		else
		{
			throw new WrongUsageException("commands.kick.usage", new Object[0]);
		}
	}

	public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
	{
		return par2ArrayOfStr.length >= 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null;
	}
}