package reborncore.common.util;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiNewChat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;

/**
 * Class stolen from SteamAgeRevolution, which I stole from BloodMagic, which was stolen from EnderCore, which stole the
 * idea from ExtraUtilities, who stole it from vanilla.
 *
 * Original class link:
 * https://github.com/SleepyTrousers/EnderCore/blob/master/src/main/java/com/enderio/core/common/util/ChatUtil.java
 */

public class ChatUtils
{
	private static final int DELETION_ID = 2525277;
	private static int lastAdded;

	private static void sendNoSpamMessages(ITextComponent[] messages)
	{
		GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();
		for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++)
		{
			chat.deleteChatLine(i);
		}
		for (int i = 0; i < messages.length; i++)
		{
			chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i);
		}
		lastAdded = DELETION_ID + messages.length - 1;
	}

	public static ITextComponent wrap(String s)
	{
		return new TextComponentString(s);
	}

	public static ITextComponent[] wrap(String... s)
	{
		ITextComponent[] ret = new ITextComponent[s.length];
		for (int i = 0; i < ret.length; i++)
		{
			ret[i] = wrap(s[i]);
		}
		return ret;
	}

	public static ITextComponent wrapFormatted(String s, Object... args)
	{
		return new TextComponentTranslation(s, args);
	}

	public static void sendChat(EntityPlayer player, String... lines)
	{
		sendChat(player, wrap(lines));
	}

	public static void sendChat(EntityPlayer player, ITextComponent... lines)
	{
		for (ITextComponent c : lines)
		{
			player.addChatComponentMessage(c);
		}
	}

	public static void sendNoSpamClient(String... lines)
	{
		sendNoSpamClient(wrap(lines));
	}

	public static void sendNoSpamClient(ITextComponent... lines)
	{
		sendNoSpamMessages(lines);
	}
}
@@ -134,190 +134,32 @@
 aft.
-entity.player.EntityPlayer;%0Aimport net.minecraft.util.text.ITextComponent;%0Aimport net.minecraft.util.text.TextComponentString;%0Aimport net.minecraft.util.text.TextComponentTranslation
+util.text.ITextComponent
 ;%0A%0A/
@@ -555,433 +555,152 @@
 D = 
-2525277;%0A%09private static int lastAdded;%0A%0A%09private static void sendNoSpamMessages(ITextComponent%5B%5D messages)%0A%09%7B%0A%09%09GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();%0A%09%09for (int i = DELETION_ID + messages.length - 1; i %3C= lastAdded; i++)%0A%09%09%7B%0A%09%09%09chat.deleteChatLine(i);%0A%09%09%7D%0A%09%09for (int i = 0; i %3C messages.length; i++
+1337; //MAKE THIS UNIQUE PER MOD THAT USES THIS%0A%0A%09public static void sendNoSpamMessages(int messageID, ITextComponent message
 )%0A
-%09
 %09%7B%0A%09%09
-%09chat.printChatMessageWithOptionalDeletion(messages%5Bi%5D, DELETION_ID + i);%0A%09%09%7D%0A%09%09lastAdded
+int deleteID
  = D
@@ -713,900 +713,150 @@
 N_ID
- + 
++
 message
-s.length - 1;%0A%09%7D%0A%0A%09public static ITextComponent wrap(String s)%0A%09%7B%0A%09%09return new TextComponentString(s);%0A%09%7D%0A%0A%09public static ITextComponent%5B%5D wrap(String... s)%0A%09%7B%0A%09%09ITextComponent%5B%5D ret = new ITextComponent%5Bs.length%5D;%0A%09%09for (int i = 0; i %3C ret.length; i++)%0A%09%09%7B%0A%09%09%09ret%5Bi%5D = wrap(s%5Bi%5D);%0A%09%09%7D%0A%09%09return ret;%0A%09%7D%0A%0A%09public static ITextComponent wrapFormatted(String s, Object... args)%0A%09%7B%0A%09%09return new TextComponentTranslation(s, args);%0A%09%7D%0A%0A%09public static void sendChat(EntityPlayer player, String... lines)%0A%09%7B%0A%09%09sendChat(player, wrap(lines));%0A%09%7D%0A%0A%09public static void sendChat(EntityPlayer player, ITextComponent... lines)%0A%09%7B%0A%09%09for (ITextComponent c : lines)%0A%09%09%7B%0A%09%09%09player.addChatComponentMessage(c);%0A%09%09%7D%0A%09%7D%0A%0A%09public static void sendNoSpamClient(String... lines)%0A%09%7B%0A%09%09sendNoSpamClient(wrap(lines));%0A%09%7D%0A%0A%09public static void sendNoSpamClient(ITextComponent... lines)%0A%09%7B%0A%09%09sendNoSpamMessages(lines
+ID;%0A%09%09GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI();%0A%09%09chat.printChatMessageWithOptionalDeletion(message, deleteID
 );%0A%09

Improve ChatUtils