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 testHoverEvent() { final C c0 = this.builder().build(); assertNull(c0.hoverEvent()); final C c1 = (C) c0.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("hover"))); assertNotNull(c1.hoverEvent()); assertEquals(c0, c1.hoverEvent(null)); }