#2750: Don't special case TextComponent constructor with a single extra

This commit is contained in:
BlackHole 2020-01-14 19:30:07 +01:00 committed by md_5
parent b70cb01413
commit b7e7274b98

View File

@ -173,26 +173,12 @@ public final class TextComponent extends BaseComponent
*/ */
public TextComponent(BaseComponent... extras) public TextComponent(BaseComponent... extras)
{ {
this();
if ( extras.length == 0 ) if ( extras.length == 0 )
{ {
return; return;
} }
if ( extras.length == 1 && extras[0] instanceof TextComponent ) setExtra( new ArrayList<BaseComponent>( Arrays.asList( extras ) ) );
{
setText( ( (TextComponent) extras[0] ).getText() );
List<BaseComponent> headExtra = extras[0].getExtra();
if ( headExtra != null )
{
for ( BaseComponent extra : headExtra )
{
addExtra( extra.duplicate() );
}
}
} else
{
setText( "" );
setExtra( new ArrayList<BaseComponent>( Arrays.asList( extras ) ) );
}
} }
/** /**