Skip to content

Commit

Permalink
api: Add Sound.Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kezz committed Apr 9, 2021
1 parent d92fcb2 commit ecd203e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions api/src/main/java/net/kyori/adventure/sound/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Type> type, final Source.@NonNull Provider source, final float volume, final float pitch) {
return sound(type, source.source(), volume, pitch);
}

/**
* Gets the name.
*
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down

0 comments on commit ecd203e

Please sign in to comment.