private <B extends BuildableComponent.Builder<?, ?>> B deepRender(final Component component, final B builder, final C context) { this.mergeStyle(component, builder, context); component.children().forEach(child -> builder.append(this.render(child, context))); return builder; }
private <B extends BuildableComponent.Builder<?, ?>> B deepRender(final Component component, final B builder, final C context) { this.mergeStyle(component, builder, context); component.children().forEach(child -> builder.append(this.render(child, context))); return builder; }
private <B extends BuildableComponent.Builder<?, ?>> B deepRender(final Component component, final B builder, final C context) { this.mergeStyle(component, builder, context); component.children().forEach(child -> builder.append(this.render(child, context))); return builder; }
public void serialize(final @NonNull StringBuilder sb, final @NonNull Component component) { if(component instanceof KeybindComponent) { sb.append(this.keybind.apply((KeybindComponent) component)); } else if(component instanceof ScoreComponent) { sb.append(((ScoreComponent) component).value()); } else if(component instanceof SelectorComponent) { sb.append(((SelectorComponent) component).pattern()); } else if(component instanceof TextComponent) { sb.append(((TextComponent) component).content()); } else if(component instanceof TranslatableComponent) { sb.append(this.translatable.apply((TranslatableComponent) component)); } else { throw new IllegalArgumentException("Don't know how to turn " + component + " into a string"); } for(final Component child : component.children()) { this.serialize(sb, child); } } }
public void serialize(final @NonNull StringBuilder sb, final @NonNull Component component) { if(component instanceof KeybindComponent) { sb.append(this.keybind.apply((KeybindComponent) component)); } else if(component instanceof ScoreComponent) { sb.append(((ScoreComponent) component).value()); } else if(component instanceof SelectorComponent) { sb.append(((SelectorComponent) component).pattern()); } else if(component instanceof TextComponent) { sb.append(((TextComponent) component).content()); } else if(component instanceof TranslatableComponent) { sb.append(this.translatable.apply((TranslatableComponent) component)); } else { throw new IllegalArgumentException("Don't know how to turn " + component + " into a string"); } for(final Component child : component.children()) { this.serialize(sb, child); } } }
private void append(final @NonNull Component component, final @NonNull Style style) { style.apply(component); if(component instanceof TextComponent) { final String content = ((TextComponent) component).content(); if(!content.isEmpty()) { style.applyFormat(); this.sb.append(content); } } final List<Component> children = component.children(); if(!children.isEmpty()) { final Style childrenStyle = new Style(style); for(final Component child : component.children()) { this.append(child, childrenStyle); childrenStyle.set(style); } } }
private void append(final @NonNull Component component, final @NonNull Style style) { style.apply(component); if(component instanceof TextComponent) { final String content = ((TextComponent) component).content(); if(!content.isEmpty()) { style.applyFormat(); this.sb.append(content); } } final List<Component> children = component.children(); if(!children.isEmpty()) { final Style childrenStyle = new Style(style); for(final Component child : component.children()) { this.append(child, childrenStyle); childrenStyle.set(style); } } }
/** * Checks if this component contains a component. * * @param that the other component * @return {@code true} if this component contains the provided * component, {@code false} otherwise */ default boolean contains(final @NonNull Component that) { if(this == that) return true; for(final Component child : this.children()) { if(child.contains(that)) return true; } if(this.hoverEvent() != null) { final Component hover = this.hoverEvent().value(); if(that == hover) return true; for(final Component child : hover.children()) { if(child.contains(that)) return true; } } return false; }
/** * Checks if this component contains a component. * * @param that the other component * @return {@code true} if this component contains the provided * component, {@code false} otherwise */ default boolean contains(final @NonNull Component that) { if(this == that) return true; for(final Component child : this.children()) { if(child.contains(that)) return true; } if(this.hoverEvent() != null) { final Component hover = this.hoverEvent().value(); if(that == hover) return true; for(final Component child : hover.children()) { if(child.contains(that)) return true; } } return false; }
/** * Checks if this component contains a component. * * @param that the other component * @return {@code true} if this component contains the provided * component, {@code false} otherwise */ default boolean contains(final @NonNull Component that) { if(this == that) return true; for(final Component child : this.children()) { if(child.contains(that)) return true; } if(this.hoverEvent() != null) { final Component hover = this.hoverEvent().value(); if(that == hover) return true; for(final Component child : hover.children()) { if(child.contains(that)) return true; } } return false; }