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); } } }
Builder(final @NonNull ScoreComponent component) { super(component); this.name = component.name(); this.objective = component.objective(); this.value = component.value(); }
Builder(final @NonNull ScoreComponent component) { super(component); this.name = component.name(); this.objective = component.objective(); this.value = component.value(); }
Builder(final @NonNull ScoreComponent component) { super(component); this.name = component.name(); this.objective = component.objective(); this.value = component.value(); }
@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; } }