@Test void testOf_color_decorations() { final TextComponent component = TextComponent.of("foo", TextColor.GREEN, ImmutableSet.of(TextDecoration.BOLD)); assertEquals("foo", component.content()); assertEquals(TextColor.GREEN, component.color()); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.OBFUSCATED)); assertEquals(TextDecoration.State.TRUE, component.decoration(TextDecoration.BOLD)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.STRIKETHROUGH)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.UNDERLINED)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.ITALIC)); }
@Test void testDecorations() { TextComponent component = TextComponent.builder().content("Kittens!").build(); // The bold decoration should not be set at this point. assertFalse(component.hasDecoration(TextDecoration.BOLD)); assertEquals(TextDecoration.State.NOT_SET, component.decoration(TextDecoration.BOLD)); component = component.decoration(TextDecoration.BOLD, TextDecoration.State.TRUE); final Set<TextDecoration> decorations = component.decorations(); // The bold decoration should be set and true at this point. assertTrue(component.hasDecoration(TextDecoration.BOLD)); assertEquals(TextDecoration.State.TRUE, component.decoration(TextDecoration.BOLD)); assertEquals(component.decoration(TextDecoration.BOLD) == TextDecoration.State.TRUE, decorations.contains(TextDecoration.BOLD)); assertTrue(decorations.contains(TextDecoration.BOLD)); assertFalse(decorations.contains(TextDecoration.OBFUSCATED)); }
@Test void testOf_color() { final TextComponent component = TextComponent.of("foo", TextColor.GREEN); assertEquals("foo", component.content()); assertEquals(TextColor.GREEN, component.color()); for(final TextDecoration decoration : TextDecoration.values()) { assertEquals(TextDecoration.State.NOT_SET, component.decoration(decoration)); } }
@Test void testOf() { final TextComponent component = TextComponent.of("foo"); assertEquals("foo", component.content()); assertNull(component.color()); for(final TextDecoration decoration : TextDecoration.values()) { assertEquals(TextDecoration.State.NOT_SET, component.decoration(decoration)); } }
@Test void testResetOverride() { final TextComponent component = TextComponent.builder("") .append(TextComponent.of("foo").color(TextColor.GREEN).decoration(TextDecoration.BOLD, TextDecoration.State.TRUE)) .append(TextComponent.of("bar").color(TextColor.DARK_GRAY)) .build(); assertEquals(component, LegacyComponentSerializer.INSTANCE.deserialize("&a&lfoo&r&8bar", '&')); }
@Test void testFromColor() { final TextComponent component = TextComponent.builder("") .append(TextComponent.of("foo").color(TextColor.GREEN).decoration(TextDecoration.BOLD, TextDecoration.State.TRUE)) .append(TextComponent.of("bar").color(TextColor.BLUE)) .build(); assertEquals(component, LegacyComponentSerializer.INSTANCE.deserialize("&a&lfoo&9bar", '&')); }
TextComponent.of("foo") .color(TextColor.GREEN) .decoration(TextDecoration.BOLD, TextDecoration.State.FALSE) TextComponent.of("you") .color(TextColor.GREEN) .decoration(TextDecoration.BOLD, TextDecoration.State.FALSE)
.decoration(TextDecoration.BOLD, true) .color(TextColor.DARK_AQUA) .append(TextComponent.of(version.getVersion()).decoration(TextDecoration.BOLD, false)) .build(); TextComponent copyright = TextComponent
TextComponent.of("foo") .color(TextColor.GREEN) .decoration(TextDecoration.BOLD, TextDecoration.State.FALSE)