/** * Creates a keybind component by applying configuration from {@code consumer}. * * @param consumer the builder configurator * @return the keybind component */ public static KeybindComponent make(final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(); consumer.accept(builder); return builder.build(); }
/** * Creates a keybind component by applying configuration from {@code consumer}. * * @param consumer the builder configurator * @return the keybind component */ public static KeybindComponent make(final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(); consumer.accept(builder); return builder.build(); }
/** * Creates a keybind component by applying configuration from {@code consumer}. * * @param consumer the builder configurator * @return the keybind component */ public static KeybindComponent make(final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(); consumer.accept(builder); return builder.build(); }
@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; } }
/** * Creates a keybind component with a keybind. * * @param keybind the keybind * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind) { return builder(keybind).build(); }
/** * Creates a keybind component by applying configuration from {@code consumer}. * * @param keybind the keybind * @param consumer the builder configurator * @return the keybind component */ public static KeybindComponent make(final @NonNull String keybind, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(keybind); consumer.accept(builder); return builder.build(); }
/** * Creates a keybind component with a keybind. * * @param keybind the keybind * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind) { return builder(keybind).build(); }
/** * Creates a keybind component by applying configuration from {@code consumer}. * * @param keybind the keybind * @param consumer the builder configurator * @return the keybind component */ public static KeybindComponent make(final @NonNull String keybind, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(keybind); consumer.accept(builder); return builder.build(); }
@Test void testRebuildWithNoChanges() { final KeybindComponent component = KeybindComponent.of("keybind.jump"); assertEquals(component, component.toBuilder().build()); } }
/** * Creates a keybind component with content, and optional color and decorations. * * @param keybind the keybind * @param color the color * @param decorations the decorations * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind, final @Nullable TextColor color, final @NonNull Set<TextDecoration> decorations) { return builder(keybind).color(color).decorations(decorations, true).build(); }
/** * Creates a keybind component with content, and optional color and decorations. * * @param keybind the keybind * @param color the color * @param decorations the decorations * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind, final @Nullable TextColor color, final @NonNull Set<TextDecoration> decorations) { return builder(keybind).color(color).decorations(decorations, true).build(); }
/** * Creates a keybind component with content, and optional color and decorations. * * @param keybind the keybind * @param color the color * @param decorations the decorations * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind, final @Nullable TextColor color, final @NonNull Set<TextDecoration> decorations) { return builder(keybind).color(color).decorations(decorations, true).build(); }
/** * Creates a keybind component with a keybind. * * @param keybind the keybind * @return the keybind component */ public static KeybindComponent of(final @NonNull String keybind) { return builder(keybind).build(); }
/** * Creates a keybind component by applying configuration from {@code consumer}. * * @param keybind the keybind * @param consumer the builder configurator * @return the keybind component */ public static KeybindComponent make(final @NonNull String keybind, final @NonNull Consumer<Builder> consumer) { final Builder builder = builder(keybind); consumer.accept(builder); return builder.build(); }