diff --git a/paper-api/src/main/java/org/bukkit/Location.java b/paper-api/src/main/java/org/bukkit/Location.java index a98da8595c..dbdf649255 100644 --- a/paper-api/src/main/java/org/bukkit/Location.java +++ b/paper-api/src/main/java/org/bukkit/Location.java @@ -298,4 +298,19 @@ public class Location implements Cloneable { public static int locToBlock(double loc) { return (int) Math.floor(loc); } + + /** + * Retrieve the distance between two locations in a world. + * + * @param loc the Location to calculate the distance to + * @return the distance between this location and the parameter + * @throws IllegalArgumentException if the location parameter is null or represents a location in a different world + */ + public double distanceTo(Location loc) throws IllegalArgumentException { + if (loc == null || loc.getWorld() != getWorld()) { + throw new IllegalArgumentException("Cannot measure distance between worlds or to null"); + } + + return toVector().distance(loc.toVector()); + } } diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java new file mode 100644 index 0000000000..1bc0135575 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -0,0 +1,25 @@ +package org.bukkit; + +/** + * A list of sounds that the server is able to send to players. + */ +public enum Sound { + BOW_FIRE(1002), + CLICK1(1001), + CLICK2(1000), + DOOR_SOUND(1003), + EXTINGUISH(1004), + RECORD_PLAY(1005), + SMOKE(2000), + STEP_SOUND(2001); + private final int soundIdentifier; + + Sound(int soundIdentifier) { + this.soundIdentifier = soundIdentifier; + } + + public int getSoundIdentifier() { + return this.soundIdentifier; + } +} + diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index e8259f8bf7..666d49dab9 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -531,7 +531,32 @@ public interface World { * @return List containing any or none BlockPopulators */ public List getPopulators(); - + + /** + * Plays a sound to just one player. + * @param player the player to play the sound for + * @param sound the {@link Sound} + * @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds + */ + public void playSound(Player player, Sound sound, int data); + + /** + * Plays a sound to all players within a default radius around a given location. + * @param location the {@link Location} around which players must be to hear the sound + * @param sound the {@link Sound} + * @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds + */ + public void playSound(Location location, Sound sound, int data); + + /** + * Plays a sound to all players within a given radius around a location. + * @param location the {@link Location} around which players must be to hear the sound + * @param sound the {@link Sound} + * @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds + * @param radius the radius around the location + */ + public void playSound(Location location, Sound sound, int data, int radius); + /** * Represents various map environment types that a world may be */