#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()
|
public boolean isEmpty()
|
||||||
{
|
{
|
||||||
return color != null || font != null || bold != null
|
return color == null && font == null && bold == null
|
||||||
|| italic != null || underlined != null
|
&& italic == null && underlined == null
|
||||||
|| strikethrough != null || obfuscated != null;
|
&& strikethrough == null && obfuscated == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.
|
* In legacy chat, colors and reset both reset all formatting.
|
||||||
* Make sure it works in combination with ComponentBuilder.
|
* Make sure it works in combination with ComponentBuilder.
|
||||||
|
Loading…
Reference in New Issue
Block a user