protected AbstractBuilder(final @NonNull C component) { this.children = new ArrayList<>(component.children()); this.color = component.color(); this.obfuscated = component.decoration(TextDecoration.OBFUSCATED); this.bold = component.decoration(TextDecoration.BOLD); this.strikethrough = component.decoration(TextDecoration.STRIKETHROUGH); this.underlined = component.decoration(TextDecoration.UNDERLINED); this.italic = component.decoration(TextDecoration.ITALIC); this.clickEvent = Optional.ofNullable(component.clickEvent()).map(ClickEvent::copy).orElse(null); this.hoverEvent = Optional.ofNullable(component.hoverEvent()).map(HoverEvent::copy).orElse(null); this.insertion = component.insertion(); }
protected AbstractBuilder(final @NonNull C component) { this.children = new ArrayList<>(component.children()); this.color = component.color(); this.obfuscated = component.decoration(TextDecoration.OBFUSCATED); this.bold = component.decoration(TextDecoration.BOLD); this.strikethrough = component.decoration(TextDecoration.STRIKETHROUGH); this.underlined = component.decoration(TextDecoration.UNDERLINED); this.italic = component.decoration(TextDecoration.ITALIC); this.clickEvent = Optional.ofNullable(component.clickEvent()).map(ClickEvent::copy).orElse(null); this.hoverEvent = Optional.ofNullable(component.hoverEvent()).map(HoverEvent::copy).orElse(null); this.insertion = component.insertion(); }
protected AbstractBuilder(final @NonNull C component) { this.children = new ArrayList<>(component.children()); this.color = component.color(); this.obfuscated = component.decoration(TextDecoration.OBFUSCATED); this.bold = component.decoration(TextDecoration.BOLD); this.strikethrough = component.decoration(TextDecoration.STRIKETHROUGH); this.underlined = component.decoration(TextDecoration.UNDERLINE); this.italic = component.decoration(TextDecoration.ITALIC); this.clickEvent = Optional.ofNullable(component.clickEvent()).map(ClickEvent::copy).orElse(null); this.hoverEvent = Optional.ofNullable(component.hoverEvent()).map(HoverEvent::copy).orElse(null); this.insertion = component.insertion(); }
@Test void testDecoration() { final C c0 = this.builder().build(); assertDecorations(c0, ImmutableMap.of()); final C c1 = (C) c0.decoration(TextDecoration.BOLD, true); assertDecorations(c1, ImmutableMap.of(TextDecoration.BOLD, TextDecoration.State.TRUE)); assertEquals(c0, c1.decoration(TextDecoration.BOLD, TextDecoration.State.NOT_SET)); }
@Test void testMergeDecorations() { final C c0 = this.builder().build(); assertNull(c0.color()); assertDecorations(c0, ImmutableMap.of()); assertNull(c0.clickEvent()); final C c1 = (C) c0.mergeDecorations(TextComponent.of("xyz", TextColor.RED, ImmutableSet.of(TextDecoration.BOLD)).clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/foo"))); assertNull(c1.color()); assertDecorations(c1, ImmutableMap.of(TextDecoration.BOLD, TextDecoration.State.TRUE)); assertNull(c1.clickEvent()); assertEquals(c0, c1.decoration(TextDecoration.BOLD, TextDecoration.State.NOT_SET)); }