mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 16:57:42 +01:00
added playSound methods to the World interface and a utility method to Location
By: sunkid <sunkid@iminurnetz.com>
This commit is contained in:
parent
b91a8f0389
commit
e8e27a86f4
@ -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());
|
||||
}
|
||||
}
|
||||
|
25
paper-api/src/main/java/org/bukkit/Sound.java
Normal file
25
paper-api/src/main/java/org/bukkit/Sound.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +523,32 @@ public interface World {
|
||||
* @return List containing any or none BlockPopulators
|
||||
*/
|
||||
public List<BlockPopulator> 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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user