mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-24 01:27:38 +01:00
#3610, 3611: inverted isEmpty method on ComponentStyle
This commit is contained in:
parent
02c5c1ee76
commit
c3f228f626
@ -186,15 +186,15 @@ public final class ComponentStyle implements Cloneable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this style has any formatting explicitly set.
|
||||
* Returns whether this style has no formatting explicitly set.
|
||||
*
|
||||
* @return true if at least one value is set, false if none are set
|
||||
* @return true if no value is set, false if at least one is set
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return color != null || font != null || bold != null
|
||||
|| italic != null || underlined != null
|
||||
|| strikethrough != null || obfuscated != null;
|
||||
return color == null && font == null && bold == null
|
||||
&& italic == null && underlined == null
|
||||
&& strikethrough == null && obfuscated == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -825,6 +825,28 @@ public class ComponentsTest
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasFormatting()
|
||||
{
|
||||
BaseComponent component = new TextComponent();
|
||||
assertFalse( component.hasFormatting() );
|
||||
|
||||
component.setBold( true );
|
||||
assertTrue( component.hasFormatting() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStyleIsEmpty()
|
||||
{
|
||||
ComponentStyle style = ComponentStyle.builder().build();
|
||||
assertTrue( style.isEmpty() );
|
||||
|
||||
style = ComponentStyle.builder()
|
||||
.bold( true )
|
||||
.build();
|
||||
assertFalse( style.isEmpty() );
|
||||
}
|
||||
|
||||
/*
|
||||
* In legacy chat, colors and reset both reset all formatting.
|
||||
* Make sure it works in combination with ComponentBuilder.
|
||||
|
Loading…
Reference in New Issue
Block a user