static @NotNull Collector<Component, ? extends ComponentBuilder<?, ?>, Component> toComponent(final @NotNull Component separator) {
    return Collector.of(
      Component::text,
      (builder, add) -> {
        if (separator != Component.empty() && !builder.children().isEmpty()) {
          builder.append(separator);
        }
        builder.append(add);
      }, (a, b) -> {
        final List<Component> aChildren = a.children();
        final TextComponent.Builder ret = Component.text().append(aChildren);
        if (!aChildren.isEmpty()) {
          ret.append(separator);
        }
        ret.append(b.children());
        return ret;
      },
      TextComponent.Builder::build
    );
  }
Create a collector that will join components using the provided separator.

@param separator the separator to join with
@return a collector that can join components
@since 4.6.0
api/src/main/java/net/kyori/adventure/text/Component.java