Move the extra check out of hasFormatting
This commit is contained in:
parent
83b0229277
commit
6641d199b3
@ -323,8 +323,7 @@ public abstract class BaseComponent
|
|||||||
return color != null || bold != null
|
return color != null || bold != null
|
||||||
|| italic != null || underlined != null
|
|| italic != null || underlined != null
|
||||||
|| strikethrough != null || obfuscated != null
|
|| strikethrough != null || obfuscated != null
|
||||||
|| hoverEvent != null || clickEvent != null
|
|| hoverEvent != null || clickEvent != null;
|
||||||
|| (extra != null && extra.size() > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,9 +8,11 @@ import com.google.gson.JsonParseException;
|
|||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent>, JsonDeserializer<TextComponent>
|
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent>, JsonDeserializer<TextComponent>
|
||||||
{
|
{
|
||||||
@ -28,7 +30,8 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
|
|||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
|
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() );
|
return new JsonPrimitive( src.getText() );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user