#2457: Allow objects in with to be translated into a string (for integer, float, etc.)

This commit is contained in:
Simon Chuu 2018-07-09 03:20:11 -04:00 committed by md_5
parent ab810744ec
commit 77b0a38c26
2 changed files with 5 additions and 5 deletions

View File

@ -71,12 +71,12 @@ public final class TranslatableComponent extends BaseComponent
List<BaseComponent> temp = new ArrayList<BaseComponent>();
for ( Object w : with )
{
if ( w instanceof String )
{
temp.add( new TextComponent( (String) w ) );
} else
if ( w instanceof BaseComponent )
{
temp.add( (BaseComponent) w );
} else
{
temp.add( new TextComponent( String.valueOf( w ) ) );
}
}
setWith( temp );

View File

@ -9,7 +9,7 @@ public class TranslatableComponentTest
@Test
public void testMissingPlaceholdersAdded()
{
TranslatableComponent testComponent = new TranslatableComponent( "Test string with %s placeholders: %s", "2", "aoeu" );
TranslatableComponent testComponent = new TranslatableComponent( "Test string with %s placeholders: %s", 2, "aoeu" );
assertEquals( "Test string with 2 placeholders: aoeu", testComponent.toPlainText() );
assertEquals( "§fTest string with §f2§f placeholders: §faoeu", testComponent.toLegacyText() );
}