Builder(final @NonNull KeybindComponent component) { super(component); this.keybind = component.keybind(); }
Builder(final @NonNull KeybindComponent component) { super(component); this.keybind = component.keybind(); }
Builder(final @NonNull KeybindComponent component) { super(component); this.keybind = component.keybind(); }
object.addProperty("selector", ((SelectorComponent) component).pattern()); } else if(component instanceof KeybindComponent) { object.addProperty("keybind", ((KeybindComponent) component).keybind()); } else { throw new IllegalArgumentException("Don't know how to serialize " + component + " as a Component");
object.addProperty("selector", ((SelectorComponent) component).pattern()); } else if(component instanceof KeybindComponent) { object.addProperty("keybind", ((KeybindComponent) component).keybind()); } else { throw new IllegalArgumentException("Don't know how to serialize " + component + " as a Component");
@Test void testMake_content() { final KeybindComponent component = KeybindComponent.make("key.jump", builder -> builder.color(TextColor.DARK_PURPLE)); assertEquals("key.jump", component.keybind()); assertEquals(TextColor.DARK_PURPLE, component.color()); }
@Test void testMake() { final KeybindComponent component = KeybindComponent.make(builder -> { builder.keybind("key.jump"); builder.color(TextColor.DARK_PURPLE); }); assertEquals("key.jump", component.keybind()); assertEquals(TextColor.DARK_PURPLE, component.color()); }
@Test void testOf() { final KeybindComponent component = KeybindComponent.of("key.jump"); assertEquals("key.jump", component.keybind()); assertNull(component.color()); for(final TextDecoration decoration : TextDecoration.values()) { assertEquals(TextDecoration.State.NOT_SET, component.decoration(decoration)); } }
@Test void testOf_color() { final KeybindComponent component = KeybindComponent.of("key.jump", TextColor.GREEN); assertEquals("key.jump", component.keybind()); assertEquals(TextColor.GREEN, component.color()); for(final TextDecoration decoration : TextDecoration.values()) { assertEquals(TextDecoration.State.NOT_SET, component.decoration(decoration)); } }
@Test void testOf_color_decorations() { final KeybindComponent component = KeybindComponent.of("key.jump", TextColor.GREEN, ImmutableSet.of(TextDecoration.BOLD)); assertEquals("key.jump", component.keybind()); 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)); }
@Override public @NonNull Component render(final @NonNull Component component, final @NonNull C context) { if(component instanceof TranslatableComponent) { return this.render((TranslatableComponent) component, context); } else if(component instanceof TextComponent) { final TextComponent.Builder builder = TextComponent.builder(((TextComponent) component).content()); return this.deepRender(component, builder, context).build(); } else if(component instanceof KeybindComponent) { final KeybindComponent.Builder builder = KeybindComponent.builder(((KeybindComponent) component).keybind()); return this.deepRender(component, builder, context).build(); } else if(component instanceof ScoreComponent) { final ScoreComponent sc = (ScoreComponent) component; final ScoreComponent.Builder builder = ScoreComponent.builder() .name(sc.name()) .objective(sc.objective()) .value(sc.value()); return this.deepRender(component, builder, context).build(); } else if(component instanceof SelectorComponent) { final SelectorComponent.Builder builder = SelectorComponent.builder(((SelectorComponent) component).pattern()); return this.deepRender(component, builder, context).build(); } else { return component; } }
@Override public @NonNull Component render(final @NonNull Component component, final @NonNull C context) { if(component instanceof TranslatableComponent) { return this.render((TranslatableComponent) component, context); } else if(component instanceof TextComponent) { final TextComponent.Builder builder = TextComponent.builder(((TextComponent) component).content()); return this.deepRender(component, builder, context).build(); } else if(component instanceof KeybindComponent) { final KeybindComponent.Builder builder = KeybindComponent.builder(((KeybindComponent) component).keybind()); return this.deepRender(component, builder, context).build(); } else if(component instanceof ScoreComponent) { final ScoreComponent sc = (ScoreComponent) component; final ScoreComponent.Builder builder = ScoreComponent.builder() .name(sc.name()) .objective(sc.objective()) .value(sc.value()); return this.deepRender(component, builder, context).build(); } else if(component instanceof SelectorComponent) { final SelectorComponent.Builder builder = SelectorComponent.builder(((SelectorComponent) component).pattern()); return this.deepRender(component, builder, context).build(); } else { return component; } }
@Override public @NonNull Component render(final @NonNull Component component, final @NonNull C context) { if(component instanceof TranslatableComponent) { return this.render((TranslatableComponent) component, context); } else if(component instanceof TextComponent) { final TextComponent.Builder builder = TextComponent.builder(((TextComponent) component).content()); return this.deepRender(component, builder, context).build(); } else if(component instanceof KeybindComponent) { final KeybindComponent.Builder builder = KeybindComponent.builder(((KeybindComponent) component).keybind()); return this.deepRender(component, builder, context).build(); } else if(component instanceof ScoreComponent) { final ScoreComponent sc = (ScoreComponent) component; final ScoreComponent.Builder builder = ScoreComponent.builder() .name(sc.name()) .objective(sc.objective()) .value(sc.value()); return this.deepRender(component, builder, context).build(); } else if(component instanceof SelectorComponent) { final SelectorComponent.Builder builder = SelectorComponent.builder(((SelectorComponent) component).pattern()); return this.deepRender(component, builder, context).build(); } else { return component; } }