diff --git a/api/src/main/java/net/kyori/adventure/text/JoinConfiguration.java b/api/src/main/java/net/kyori/adventure/text/JoinConfiguration.java index 19ee8b175..44709a988 100644 --- a/api/src/main/java/net/kyori/adventure/text/JoinConfiguration.java +++ b/api/src/main/java/net/kyori/adventure/text/JoinConfiguration.java @@ -118,6 +118,19 @@ public interface JoinConfiguration extends BuildableA purely text based example of this syntax, without introducing the concepts of components, would join the two strings 'hello' and 'there' together, + * creating the following output: 'hello there'.

+ * + * @return the join configuration + * @since 4.15.0 + */ + static @NotNull JoinConfiguration spaces() { + return JoinConfigurationImpl.STANDARD_SPACES; + } + /** * Provides a join configuration with no prefix or suffix that simply joins the components together using a single comma, matching a CSV like layout. * diff --git a/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java b/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java index 135392c17..621a0ccfb 100644 --- a/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java +++ b/api/src/main/java/net/kyori/adventure/text/JoinConfigurationImpl.java @@ -41,6 +41,7 @@ final class JoinConfigurationImpl implements JoinConfiguration { static final JoinConfigurationImpl NULL = new JoinConfigurationImpl(); static final JoinConfiguration STANDARD_NEW_LINES = JoinConfiguration.separator(Component.newline()); + static final JoinConfiguration STANDARD_SPACES = JoinConfiguration.separator(Component.space()); static final JoinConfiguration STANDARD_COMMA_SEPARATED = JoinConfiguration.separator(Component.text(",")); static final JoinConfiguration STANDARD_COMMA_SPACE_SEPARATED = JoinConfiguration.separator(Component.text(", ")); static final JoinConfiguration STANDARD_ARRAY_LIKE = JoinConfiguration.builder() diff --git a/api/src/test/java/net/kyori/adventure/text/JoinTest.java b/api/src/test/java/net/kyori/adventure/text/JoinTest.java index 6f11ca243..2a74f2110 100644 --- a/api/src/test/java/net/kyori/adventure/text/JoinTest.java +++ b/api/src/test/java/net/kyori/adventure/text/JoinTest.java @@ -276,6 +276,21 @@ final void testStandardJoinConfigurationsNewLines() { ); } + @Test + final void testStandardJoinConfigurationsSpaces() { + final Component result = Component.join(JoinConfiguration.spaces(), Component.text("line 1"), Component.text("line 2"), Component.text("line 3")); + assertEquals( + Component.text() + .append(Component.text("line 1")) + .append(Component.space()) + .append(Component.text("line 2")) + .append(Component.space()) + .append(Component.text("line 3")) + .build(), + result + ); + } + @Test final void testStandardJoinConfigurationsCommas() { final Component result = Component.join(JoinConfiguration.commas(false), Component.text("line 1"), Component.text("line 2"), Component.text("line 3"));