mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-20 15:48:01 +01:00
#3665: Small improvements to TranslatableComponent
* Make TranslatableComponent format Pattern static * Fix TranslatableComponent copy constructor not copying fallback
This commit is contained in:
parent
d110f6629b
commit
336333acb1
@ -19,7 +19,7 @@ import net.md_5.bungee.chat.TranslationRegistry;
|
|||||||
public final class TranslatableComponent extends BaseComponent
|
public final class TranslatableComponent extends BaseComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Pattern format = Pattern.compile( "%(?:(\\d+)\\$)?([A-Za-z%]|$)" );
|
private static final Pattern FORMAT = Pattern.compile( "%(?:(\\d+)\\$)?([A-Za-z%]|$)" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key into the Minecraft locale files to use for the translation. The
|
* The key into the Minecraft locale files to use for the translation. The
|
||||||
@ -44,10 +44,11 @@ public final class TranslatableComponent extends BaseComponent
|
|||||||
{
|
{
|
||||||
super( original );
|
super( original );
|
||||||
setTranslate( original.getTranslate() );
|
setTranslate( original.getTranslate() );
|
||||||
|
setFallback( original.getFallback() );
|
||||||
|
|
||||||
if ( original.getWith() != null )
|
if ( original.getWith() != null )
|
||||||
{
|
{
|
||||||
List<BaseComponent> temp = new ArrayList<BaseComponent>();
|
List<BaseComponent> temp = new ArrayList<>();
|
||||||
for ( BaseComponent baseComponent : original.getWith() )
|
for ( BaseComponent baseComponent : original.getWith() )
|
||||||
{
|
{
|
||||||
temp.add( baseComponent.duplicate() );
|
temp.add( baseComponent.duplicate() );
|
||||||
@ -177,7 +178,7 @@ public final class TranslatableComponent extends BaseComponent
|
|||||||
trans = fallback;
|
trans = fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher matcher = format.matcher( trans );
|
Matcher matcher = FORMAT.matcher( trans );
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ( matcher.find( position ) )
|
while ( matcher.find( position ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user