package org.spacehq.mc.protocol.data.message;

import java.util.ArrayList;
import java.util.List;

public class MessageStyle implements Cloneable {

	private ChatColor color = ChatColor.WHITE;
	private List<ChatFormat> formats = new ArrayList<ChatFormat>();
	private ClickEvent click;
	private HoverEvent hover;
	private String insertion;
	private MessageStyle parent;

	public MessageStyle() {
	}

	public MessageStyle(MessageStyle parent) {
		this.parent = parent;
	}

	public boolean isDefault() {
		return (this.color == ChatColor.WHITE && (this.parent == null || this.parent.getColor() == ChatColor.WHITE)) && this.formats.isEmpty() && (this.parent == null || this.parent.getFormats().isEmpty()) && this.click == null && this.hover == null && this.insertion == null;
	}

	public ChatColor getColor() {
		return this.color;
	}

	public List<ChatFormat> getFormats() {
		return new ArrayList<ChatFormat>(this.formats);
	}

	public ClickEvent getClickEvent() {
		return this.click;
	}

	public HoverEvent getHoverEvent() {
		return this.hover;
	}

	public String getInsertion() {
		return this.insertion;
	}

	public MessageStyle getParent() {
		return this.parent != null ? this.parent : new MessageStyle();
	}

	public MessageStyle setColor(ChatColor color) {
		this.color = color;
		return this;
	}

	public MessageStyle setFormats(List<ChatFormat> formats) {
		this.formats = new ArrayList<ChatFormat>(formats);
		return this;
	}

	public MessageStyle addFormat(ChatFormat format) {
		this.formats.add(format);
		return this;
	}

	public MessageStyle removeFormat(ChatFormat format) {
		this.formats.remove(format);
		return this;
	}

	public MessageStyle clearFormats() {
		this.formats.clear();
		return this;
	}

	public MessageStyle setClickEvent(ClickEvent event) {
		this.click = event;
		return this;
	}

	public MessageStyle setHoverEvent(HoverEvent event) {
		this.hover = event;
		return this;
	}

	public MessageStyle setInsertion(String insertion) {
		this.insertion = insertion;
		return this;
	}

	protected MessageStyle setParent(MessageStyle parent) {
		this.parent = parent;
		return this;
	}

	@Override
	public String toString() {
		return "MessageStyle{color=" + this.color + ",formats=" + this.formats + ",clickEvent=" + this.click + ",hoverEvent=" + this.hover + ",insertion=" + this.insertion + "}";
	}

	@Override
	public MessageStyle clone() {
		return (this.parent != null ? new MessageStyle(this.parent) : new MessageStyle()).setColor(this.color).setFormats(this.formats).setClickEvent(this.click != null ? this.click.clone() : this.click).setHoverEvent(this.hover != null ? this.hover.clone() : this.hover).setInsertion(this.insertion);
	}

}

@@ -360,18 +360,39 @@
 e parent
+ = new MessageStyle()
 ;%0A
-
 %0A%09public
@@ -520,25 +520,24 @@
  %7B%0A%09%09return 
-(
 this.color =
@@ -542,147 +542,69 @@
  == 
-ChatColor.WHITE && (this.parent == null %7C%7C this.parent.getColor() == ChatColor.WHITE)) && this.formats.isEmpty() && (this.parent == null %7C%7C
+this.parent.getColor() && this.formatListsEqual(this.formats,
  thi
@@ -628,18 +628,8 @@
 ts()
-.isEmpty()
 ) &&
@@ -1095,51 +1095,8 @@
 rent
- != null ? this.parent : new MessageStyle()
 ;%0A%09%7D
@@ -1948,32 +1948,92 @@
 Style parent) %7B%0A
+%09%09if(parent == null) %7B%0A%09%09%09parent = new MessageStyle();%0A%09%09%7D%0A%0A
 %09%09this.parent = 
@@ -2329,31 +2329,8 @@
 turn
- (this.parent != null ?
  new
@@ -2359,30 +2359,8 @@
 ent)
- : new MessageStyle())
 .set
@@ -2572,10 +2572,250 @@
 n);%0A%09%7D%0A%0A
+%09private boolean formatListsEqual(List%3CChatFormat%3E l1, List%3CChatFormat%3E l2) %7B%0A%09%09if(l1.size() != l2.size()) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%0A%09%09for(ChatFormat format : l1) %7B%0A%09%09%09if(!l2.contains(format)) %7B%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return true;%0A%09%7D%0A%0A
 %7D%0A

Change default to check if style equals parent style rather than WHITE and no formatting.