mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-30 14:13:47 +01:00
#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.
|
||||
* <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
|
||||
*/
|
||||
|
@ -18,6 +18,9 @@ public final class ComponentStyle implements Cloneable
|
||||
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
|
@ -155,6 +155,17 @@ public class ComponentsTest
|
||||
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
|
||||
public void testComponentParting()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user