package net.minecraft.command;

import java.util.Iterator;
import net.minecraft.command.server.CommandAchievement;
import net.minecraft.command.server.CommandBanIp;
import net.minecraft.command.server.CommandBanPlayer;
import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.command.server.CommandBroadcast;
import net.minecraft.command.server.CommandDeOp;
import net.minecraft.command.server.CommandEmote;
import net.minecraft.command.server.CommandListBans;
import net.minecraft.command.server.CommandListPlayers;
import net.minecraft.command.server.CommandMessage;
import net.minecraft.command.server.CommandMessageRaw;
import net.minecraft.command.server.CommandOp;
import net.minecraft.command.server.CommandPardonIp;
import net.minecraft.command.server.CommandPardonPlayer;
import net.minecraft.command.server.CommandPublishLocalServer;
import net.minecraft.command.server.CommandSaveAll;
import net.minecraft.command.server.CommandSaveOff;
import net.minecraft.command.server.CommandSaveOn;
import net.minecraft.command.server.CommandScoreboard;
import net.minecraft.command.server.CommandSetBlock;
import net.minecraft.command.server.CommandSetDefaultSpawnpoint;
import net.minecraft.command.server.CommandStop;
import net.minecraft.command.server.CommandSummon;
import net.minecraft.command.server.CommandTeleport;
import net.minecraft.command.server.CommandTestFor;
import net.minecraft.command.server.CommandTestForBlock;
import net.minecraft.command.server.CommandWhitelist;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;

public class ServerCommandManager extends CommandHandler implements IAdminCommand
{
	private static final String __OBFID = "CL_00000922";

	public ServerCommandManager()
	{
		this.registerCommand(new CommandTime());
		this.registerCommand(new CommandGameMode());
		this.registerCommand(new CommandDifficulty());
		this.registerCommand(new CommandDefaultGameMode());
		this.registerCommand(new CommandKill());
		this.registerCommand(new CommandToggleDownfall());
		this.registerCommand(new CommandWeather());
		this.registerCommand(new CommandXP());
		this.registerCommand(new CommandTeleport());
		this.registerCommand(new CommandGive());
		this.registerCommand(new CommandEffect());
		this.registerCommand(new CommandEnchant());
		this.registerCommand(new CommandEmote());
		this.registerCommand(new CommandShowSeed());
		this.registerCommand(new CommandHelp());
		this.registerCommand(new CommandDebug());
		this.registerCommand(new CommandMessage());
		this.registerCommand(new CommandBroadcast());
		this.registerCommand(new CommandSetSpawnpoint());
		this.registerCommand(new CommandSetDefaultSpawnpoint());
		this.registerCommand(new CommandGameRule());
		this.registerCommand(new CommandClearInventory());
		this.registerCommand(new CommandTestFor());
		this.registerCommand(new CommandSpreadPlayers());
		this.registerCommand(new CommandPlaySound());
		this.registerCommand(new CommandScoreboard());
		this.registerCommand(new CommandAchievement());
		this.registerCommand(new CommandSummon());
		this.registerCommand(new CommandSetBlock());
		this.registerCommand(new CommandTestForBlock());
		this.registerCommand(new CommandMessageRaw());

		if (MinecraftServer.getServer().isDedicatedServer())
		{
			this.registerCommand(new CommandOp());
			this.registerCommand(new CommandDeOp());
			this.registerCommand(new CommandStop());
			this.registerCommand(new CommandSaveAll());
			this.registerCommand(new CommandSaveOff());
			this.registerCommand(new CommandSaveOn());
			this.registerCommand(new CommandBanIp());
			this.registerCommand(new CommandPardonIp());
			this.registerCommand(new CommandBanPlayer());
			this.registerCommand(new CommandListBans());
			this.registerCommand(new CommandPardonPlayer());
			this.registerCommand(new CommandServerKick());
			this.registerCommand(new CommandListPlayers());
			this.registerCommand(new CommandWhitelist());
			this.registerCommand(new CommandSetPlayerTimeout());
		}
		else
		{
			this.registerCommand(new CommandPublishLocalServer());
		}

		CommandBase.setAdminCommander(this);
	}

	public void notifyAdmins(ICommandSender par1ICommandSender, int par2, String par3Str, Object ... par4ArrayOfObj)
	{
		boolean flag = true;

		if (par1ICommandSender instanceof CommandBlockLogic && !MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput"))
		{
			flag = false;
		}

		ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.type.admin", new Object[] {par1ICommandSender.getCommandSenderName(), new ChatComponentTranslation(par3Str, par4ArrayOfObj)});
		chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY);
		chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true));

		if (flag)
		{
			Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();

			while (iterator.hasNext())
			{
				EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next();

				if (entityplayermp != par1ICommandSender && MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(entityplayermp.getCommandSenderName()))
				{
					entityplayermp.addChatMessage(chatcomponenttranslation);
				}
			}
		}

		if (par1ICommandSender != MinecraftServer.getServer())
		{
			MinecraftServer.getServer().addChatMessage(chatcomponenttranslation);
		}

		if ((par2 & 1) != 1)
		{
			par1ICommandSender.addChatMessage(new ChatComponentTranslation(par3Str, par4ArrayOfObj));
		}
	}
}