Move the extra check out of hasFormatting

This commit is contained in:
Thinkofdeath 2014-01-26 00:41:13 +00:00
parent 83b0229277
commit 6641d199b3
2 changed files with 5 additions and 3 deletions

View File

@ -323,8 +323,7 @@ public abstract class BaseComponent
return color != null || bold != null
|| italic != null || underlined != null
|| strikethrough != null || obfuscated != null
|| hoverEvent != null || clickEvent != null
|| (extra != null && extra.size() > 0);
|| hoverEvent != null || clickEvent != null;
}
/**

View File

@ -8,9 +8,11 @@ import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import java.lang.reflect.Type;
import java.util.List;
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent>, JsonDeserializer<TextComponent>
{
@ -28,7 +30,8 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
@Override
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
{
if ( !src.hasFormatting() )
List<BaseComponent> extra = src.getExtra();
if ( !src.hasFormatting() && (extra == null || extra.size() > 0) )
{
return new JsonPrimitive( src.getText() );
}