diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java b/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java index ea3520454..a9e3b6293 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentBuilder.java @@ -24,6 +24,7 @@ package net.kyori.adventure.text; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; @@ -273,6 +274,24 @@ public interface ComponentBuilder, B extends return this.decoration(decoration, TextDecoration.State.byBoolean(flag)); } + /** + * Sets decorations for this component's style using the specified {@code decorations} map. + * + *

If a given decoration does not have a value explicitly set, the value of that particular decoration is not changed.

+ * + * @param decorations a map containing text decorations and their respective state. + * @return this builder + * @since 4.10.0 + */ + @Contract("_ -> this") + @SuppressWarnings("unchecked") + default @NotNull B decorations(final @NotNull Map decorations) { + for (final Map.Entry entry : decorations.entrySet()) { + this.decoration(entry.getKey(), entry.getValue()); + } + return (B) this; + } + /** * Sets the value of a decoration on this component. * diff --git a/api/src/main/java/net/kyori/adventure/text/format/Style.java b/api/src/main/java/net/kyori/adventure/text/format/Style.java index 56c488630..09ffd8dc6 100644 --- a/api/src/main/java/net/kyori/adventure/text/format/Style.java +++ b/api/src/main/java/net/kyori/adventure/text/format/Style.java @@ -689,6 +689,23 @@ interface Builder extends Buildable.Builder