package monoxide.forgebackup;

import java.util.Iterator;
import java.util.logging.Level;

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntityCommandBlock;
import cpw.mods.fml.common.registry.LanguageRegistry;

public abstract class CommandBackupBase extends CommandBase {
	protected final MinecraftServer server;
	
	public CommandBackupBase(MinecraftServer server) {
		this.server = MinecraftServer.getServer();
		((ServerCommandManager) this.server.getCommandManager()).registerCommand(this);
	}
	
	public void notifyBackupAdmins(ICommandSender sender, String translationKey, Object... parameters) {
		notifyBackupAdmins(sender, Level.INFO, translationKey, parameters);
	}
	
	public void notifyBackupAdmins(ICommandSender sender, Level level, String translationKey, Object... parameters) {
		boolean var5 = true;
		String message = String.format(LanguageRegistry.instance().getStringLocalization(translationKey), parameters);
		
		if (sender instanceof TileEntityCommandBlock && !server.worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput"))
		{
			var5 = false;
		}
		
		if (var5)
		{
			Iterator var6 = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
			
			while (var6.hasNext())
			{
				EntityPlayerMP var7 = (EntityPlayerMP)var6.next();
				
				if (var7 != sender && server.getConfigurationManager().areCommandsAllowed(var7.username))
				{
					var7.sendChatToPlayer("\u00a77\u00a7o[" + sender.getCommandSenderName() + ": " + message + "]");
				}
			}
		}
		
		if (sender != MinecraftServer.getServer())
		{
			BackupLog.log(level, message);
		}
	}
}

@@ -226,24 +226,74 @@
 ndManager;%0D%0A
+import net.minecraft.entity.player.EntityPlayer;%0D%0A
 import net.m
@@ -1438,35 +1438,14 @@
 6 = 
-MinecraftServer.getServer()
+server
 .get
@@ -1844,35 +1844,14 @@
  != 
-MinecraftServer.getServer()
+server
 )%0D%0A%09
@@ -1894,15 +1894,146 @@
 ;%0D%0A%09%09%7D%0D%0A
+%09%09if (sender instanceof EntityPlayer && !server.isDedicatedServer()) %7B%0D%0A%09%09%09((EntityPlayer)sender).sendChatToPlayer(message);%0D%0A%09%09%7D%0D%0A
 %09%7D%0D%0A%7D%0D%0A

Send messages to player in SSP when run manually.