File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
bukkit-utils/src/main/java/com/wizardlybump17/wlib/util/bukkit/collector Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 33import net .kyori .adventure .text .Component ;
44import org .jetbrains .annotations .NotNull ;
55
6+ import java .util .Objects ;
67import java .util .Set ;
78import java .util .function .BiConsumer ;
89import java .util .function .BinaryOperator ;
@@ -24,25 +25,33 @@ public ComponentCollector(@NotNull Component separator) {
2425
2526 @ Override
2627 public @ NotNull Supplier <Component []> supplier () {
27- return () -> new Component [] { Component . empty ()} ;
28+ return () -> new Component [1 ] ;
2829 }
2930
3031 @ Override
3132 public @ NotNull BiConsumer <Component [], Component > accumulator () {
32- return (array , component ) -> array [0 ] = array [0 ].append (separator ).append (component );
33+ return (array , component ) -> {
34+ if (array [0 ] == null )
35+ array [0 ] = component ;
36+ else
37+ array [0 ] = array [0 ].append (separator ).append (component );
38+ };
3339 }
3440
3541 @ Override
3642 public @ NotNull BinaryOperator <Component []> combiner () {
3743 return (left , right ) -> {
38- left [0 ] = left [0 ].append (separator ).append (right [0 ]);
44+ if (left [0 ] == null )
45+ left [0 ] = right [0 ];
46+ else
47+ left [0 ] = left [0 ].append (separator ).append (right [0 ]);
3948 return left ;
4049 };
4150 }
4251
4352 @ Override
4453 public @ NotNull Function <Component [], Component > finisher () {
45- return array -> array [0 ];
54+ return array -> Objects . requireNonNullElseGet ( array [0 ], Component :: empty ) ;
4655 }
4756
4857 @ Override
You can’t perform that action at this time.
0 commit comments