From 1396386f235a4e5dfab21e15749072a6aefae225 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 19 Nov 2016 14:19:53 +1100 Subject: [PATCH] Implement SoundCategory for playing sounds. By: LukBukkit --- .../main/java/org/bukkit/SoundCategory.java | 18 ++++++++++++ paper-api/src/main/java/org/bukkit/World.java | 28 ++++++++++++++++++ .../main/java/org/bukkit/entity/Player.java | 29 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/SoundCategory.java diff --git a/paper-api/src/main/java/org/bukkit/SoundCategory.java b/paper-api/src/main/java/org/bukkit/SoundCategory.java new file mode 100644 index 0000000000..ac5e263d73 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/SoundCategory.java @@ -0,0 +1,18 @@ +package org.bukkit; + +/** + * An Enum of categories for sounds. + */ +public enum SoundCategory { + + MASTER, + MUSIC, + RECORDS, + WEATHER, + BLOCKS, + HOSTILE, + NEUTRAL, + PLAYERS, + AMBIENT, + VOICE; +} diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index c14840a203..8dd254aa7d 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -1155,6 +1155,34 @@ public interface World extends PluginMessageRecipient, Metadatable { */ void playSound(Location location, String sound, float volume, float pitch); + /** + * Play a Sound at the provided Location in the World. + *

+ * This function will fail silently if Location or Sound are null. + * + * @param location The location to play the sound + * @param sound The sound to play + * @param category the category of the sound + * @param volume The volume of the sound + * @param pitch The pitch of the sound + */ + void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch); + + /** + * Play a Sound at the provided Location in the World. + *

+ * This function will fail silently if Location or Sound are null. No sound + * will be heard by the players if their clients do not have the respective + * sound for the value passed. + * + * @param location the location to play the sound + * @param sound the internal sound name to play + * @param category the category of the sound + * @param volume the volume of the sound + * @param pitch the pitch of the sound + */ + void playSound(Location location, String sound, SoundCategory category, float volume, float pitch); + /** * Get existing rules * diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index 73816a0580..d3210229f7 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -13,6 +13,7 @@ import org.bukkit.Note; import org.bukkit.OfflinePlayer; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.Statistic; import org.bukkit.WeatherType; import org.bukkit.command.CommandSender; @@ -241,6 +242,34 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline */ public void playSound(Location location, String sound, float volume, float pitch); + /** + * Play a sound for a player at the location. + *

+ * This function will fail silently if Location or Sound are null. + * + * @param location The location to play the sound + * @param sound The sound to play + * @param category The category of the sound + * @param volume The volume of the sound + * @param pitch The pitch of the sound + */ + public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch); + + /** + * Play a sound for a player at the location. + *

+ * This function will fail silently if Location or Sound are null. No sound + * will be heard by the player if their client does not have the respective + * sound for the value passed. + * + * @param location the location to play the sound + * @param sound the internal sound name to play + * @param category The category of the sound + * @param volume the volume of the sound + * @param pitch the pitch of the sound + */ + public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch); + /** * Stop the specified sound from playing. *