mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 12:46:05 +01:00
#2457: Allow objects in with
to be translated into a string (for integer, float, etc.)
This commit is contained in:
parent
ab810744ec
commit
77b0a38c26
@ -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 );
|
||||
|
@ -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() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user