diff --git a/api/src/main/java/net/kyori/adventure/audience/Audience.java b/api/src/main/java/net/kyori/adventure/audience/Audience.java index 0279ce9ef..6d66b23be 100644 --- a/api/src/main/java/net/kyori/adventure/audience/Audience.java +++ b/api/src/main/java/net/kyori/adventure/audience/Audience.java @@ -41,6 +41,7 @@ import net.kyori.adventure.resource.ResourcePackInfo; import net.kyori.adventure.resource.ResourcePackInfoLike; import net.kyori.adventure.resource.ResourcePackRequest; +import net.kyori.adventure.resource.ResourcePackRequestLike; import net.kyori.adventure.sound.Sound; import net.kyori.adventure.sound.SoundStop; import net.kyori.adventure.text.Component; @@ -725,6 +726,20 @@ default void sendResourcePacks(final @NotNull ResourcePackInfoLike first, final this.sendResourcePacks(ResourcePackRequest.addingRequest(first, others)); } + /** + * Sends a request to apply resource packs to this audience. + * + *
Multiple resource packs are only supported since 1.20.3. On older versions, all requests behave as if {@link ResourcePackRequest#replace()} is set to {@code true}.
+ * + * @param request the resource pack request + * @see ResourcePackInfo + * @since 4.15.0 + */ + @ForwardingAudienceOverrideNotRequired + default void sendResourcePacks(final @NotNull ResourcePackRequestLike request) { + this.sendResourcePacks(request.asResourcePackRequest()); + } + /** * Sends a request to apply resource packs to this audience. * @@ -737,6 +752,18 @@ default void sendResourcePacks(final @NotNull ResourcePackInfoLike first, final default void sendResourcePacks(final @NotNull ResourcePackRequest request) { } + /** + * Clear resource packs with the IDs used in the provided requests if they are present. + * + * @param request the request used to originally apply the packs + * @since 4.15.0 + * @sinceMinecraft 1.20.3 + */ + @ForwardingAudienceOverrideNotRequired + default void removeResourcePacks(final @NotNull ResourcePackRequestLike request) { + this.removeResourcePacks(request.asResourcePackRequest()); + } + /** * Clear resource packs with the IDs used in the provided requests if they are present. * diff --git a/api/src/main/java/net/kyori/adventure/resource/ResourcePackRequest.java b/api/src/main/java/net/kyori/adventure/resource/ResourcePackRequest.java index a56b6a300..304f970d5 100644 --- a/api/src/main/java/net/kyori/adventure/resource/ResourcePackRequest.java +++ b/api/src/main/java/net/kyori/adventure/resource/ResourcePackRequest.java @@ -37,7 +37,7 @@ * * @since 4.15.0 */ -public interface ResourcePackRequest extends Examinable { +public interface ResourcePackRequest extends Examinable, ResourcePackRequestLike { /** * Create a basic request to apply the provided resource packs. * @@ -125,12 +125,17 @@ public interface ResourcePackRequest extends Examinable { */ @NotNull ResourcePackRequest replace(final boolean replace); + @Override + default @NotNull ResourcePackRequest asResourcePackRequest() { + return this; + } + /** * A builder for resource pack requests. * * @since 4.15.0 */ - interface Builder extends AbstractBuilder