From ecd203e73548a2cc14ec590c82e71306c1c43b7b Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Fri, 9 Apr 2021 11:42:44 +0100 Subject: [PATCH 1/2] api: Add Sound.Provider --- .../java/net/kyori/adventure/sound/Sound.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/api/src/main/java/net/kyori/adventure/sound/Sound.java b/api/src/main/java/net/kyori/adventure/sound/Sound.java index 8c0476a87..75d30b9d1 100644 --- a/api/src/main/java/net/kyori/adventure/sound/Sound.java +++ b/api/src/main/java/net/kyori/adventure/sound/Sound.java @@ -112,6 +112,48 @@ public interface Sound extends Examinable { }; } + /** + * Creates a new sound. + * + * @param name the name + * @param source the source + * @param volume the volume + * @param pitch the pitch + * @return the sound + * @since 4.8.0 + */ + static @NonNull Sound sound(final @NonNull Key name, final Source.@NonNull Provider source, final float volume, final float pitch) { + return sound(name, source.source(), volume, pitch); + } + + /** + * Creates a new sound. + * + * @param type the type + * @param source the source + * @param volume the volume + * @param pitch the pitch + * @return the sound + * @since 4.8.0 + */ + static @NonNull Sound sound(final @NonNull Type type, final Source.@NonNull Provider source, final float volume, final float pitch) { + return sound(type, source.source(), volume, pitch); + } + + /** + * Creates a new sound. + * + * @param type the type + * @param source the source + * @param volume the volume + * @param pitch the pitch + * @return the sound + * @since 4.8.0 + */ + static @NonNull Sound sound(final @NonNull Supplier type, final Source.@NonNull Provider source, final float volume, final float pitch) { + return sound(type, source.source(), volume, pitch); + } + /** * Gets the name. * @@ -172,6 +214,21 @@ enum Source { Source(final String name) { this.name = name; } + + /** + * A provider of sound sources. + * + * @since 4.8.0 + */ + public interface Provider { + /** + * Gets the source. + * + * @return the source + * @since 4.8.0 + */ + @NonNull Source source(); + } } /** From fb32d8afd8322f8eddeca53066e78804013fd489 Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Mon, 10 May 2021 16:57:07 +0100 Subject: [PATCH 2/2] Rename source to soundSource --- api/src/main/java/net/kyori/adventure/sound/Sound.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/net/kyori/adventure/sound/Sound.java b/api/src/main/java/net/kyori/adventure/sound/Sound.java index 75d30b9d1..225c51864 100644 --- a/api/src/main/java/net/kyori/adventure/sound/Sound.java +++ b/api/src/main/java/net/kyori/adventure/sound/Sound.java @@ -123,7 +123,7 @@ public interface Sound extends Examinable { * @since 4.8.0 */ static @NonNull Sound sound(final @NonNull Key name, final Source.@NonNull Provider source, final float volume, final float pitch) { - return sound(name, source.source(), volume, pitch); + return sound(name, source.soundSource(), volume, pitch); } /** @@ -137,7 +137,7 @@ public interface Sound extends Examinable { * @since 4.8.0 */ static @NonNull Sound sound(final @NonNull Type type, final Source.@NonNull Provider source, final float volume, final float pitch) { - return sound(type, source.source(), volume, pitch); + return sound(type, source.soundSource(), volume, pitch); } /** @@ -151,7 +151,7 @@ public interface Sound extends Examinable { * @since 4.8.0 */ static @NonNull Sound sound(final @NonNull Supplier type, final Source.@NonNull Provider source, final float volume, final float pitch) { - return sound(type, source.source(), volume, pitch); + return sound(type, source.soundSource(), volume, pitch); } /** @@ -227,7 +227,7 @@ public interface Provider { * @return the source * @since 4.8.0 */ - @NonNull Source source(); + @NonNull Source soundSource(); } }