#3844: Fix parsing nested array chat components
This commit is contained in:
parent
b60c1bdb37
commit
5348aad094
@ -261,6 +261,18 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
|
|||||||
{
|
{
|
||||||
return new TextComponent( json.getAsString() );
|
return new TextComponent( json.getAsString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( json.isJsonArray() )
|
||||||
|
{
|
||||||
|
JsonArray arr = json.getAsJsonArray();
|
||||||
|
BaseComponent[] components = new BaseComponent[arr.size()];
|
||||||
|
for ( int i = 0; i < arr.size(); i++ )
|
||||||
|
{
|
||||||
|
components[i] = deserialize( arr.get( i ), BaseComponent.class, context );
|
||||||
|
}
|
||||||
|
return TextComponent.fromArray( components );
|
||||||
|
}
|
||||||
|
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
if ( object.has( "translate" ) )
|
if ( object.has( "translate" ) )
|
||||||
{
|
{
|
||||||
|
@ -877,4 +877,11 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
|
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testArrayParsing()
|
||||||
|
{
|
||||||
|
assertEquals( "Outfluencer is very cool bdfg28dhzcathisisacoolcomponent",
|
||||||
|
ComponentSerializer.deserialize( "[Outfluencer,[\" \",is,[\" very\",\" cool \",[b,dfg28dhz,[c,[a,thisisacoolcomponent]]]]]]" ).toPlainText() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user