#3621: Warn about use of valid chat colors and add test
This commit is contained in:
parent
f224787222
commit
6ab0f5eba7
@ -253,6 +253,9 @@ public abstract class BaseComponent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this component's color.
|
* Set this component's color.
|
||||||
|
* <p>
|
||||||
|
* <b>Warning: This should be a color, not formatting code (ie,
|
||||||
|
* {@link ChatColor#getColor()} should not be null).</b>
|
||||||
*
|
*
|
||||||
* @param color the component color, or null to use the default
|
* @param color the component color, or null to use the default
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,9 @@ public final class ComponentStyle implements Cloneable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of this style.
|
* The color of this style.
|
||||||
|
* <p>
|
||||||
|
* <b>Warning: This should be a color, not formatting code (ie,
|
||||||
|
* {@link ChatColor#getColor()} should not be null).</b>
|
||||||
*/
|
*/
|
||||||
private ChatColor color;
|
private ChatColor color;
|
||||||
/**
|
/**
|
||||||
|
@ -155,6 +155,17 @@ public class ComponentsTest
|
|||||||
assertThrows( IndexOutOfBoundsException.class, () -> builder.getComponent( 1 ) );
|
assertThrows( IndexOutOfBoundsException.class, () -> builder.getComponent( 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFormatNotColor()
|
||||||
|
{
|
||||||
|
BaseComponent[] component = new ComponentBuilder().color( ChatColor.BOLD ).append( "Test" ).create();
|
||||||
|
|
||||||
|
String json = ComponentSerializer.toString( component );
|
||||||
|
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
||||||
|
|
||||||
|
assertNull( parsed[0].getColorRaw(), "Format should not be preserved as color" );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComponentParting()
|
public void testComponentParting()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user