Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sound source provider #328

Merged
merged 2 commits into from May 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions api/src/main/java/net/kyori/adventure/sound/Sound.java
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.soundSource(), 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.soundSource(), 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.soundSource(), 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 soundSource();
}
}

/**
Expand Down