Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add two utils & deleted old class
  • Loading branch information
vmarchaud committed May 25, 2015
1 parent f4ca719 commit 2c0b881
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 268 deletions.
100 changes: 0 additions & 100 deletions src/main/java/net/bridgesapi/tools/Area.java

This file was deleted.

41 changes: 0 additions & 41 deletions src/main/java/net/bridgesapi/tools/GameUtils.java

This file was deleted.

69 changes: 0 additions & 69 deletions src/main/java/net/bridgesapi/tools/JsonModMessage.java

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/java/net/bridgesapi/tools/JsonPrivateMessage.java

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/java/net/bridgesapi/tools/Rainbow.java

This file was deleted.

88 changes: 88 additions & 0 deletions src/main/java/net/bridgesapi/utils/SoundUtils.java
@@ -0,0 +1,88 @@
package net.bridgesapi.utils;


import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

/**
* Created by Mac' on 23/05/2015.
*/
public class SoundUtils {

/**
* @param sound - The sound that you want to be played to players
*/
public static void broadcastSound(Sound sound) {
for(Player p : Bukkit.getOnlinePlayers()) {
p.playSound(p.getLocation(), sound, 1, 1);
}
}

/**
* @param sound The sound that you want to be played to players
* @param volume The volume that player will hear sound
*/
public static void broadcastSound(Sound sound, int volume) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.playSound(player.getPlayer().getPlayer().getLocation(), sound, volume, 1);
}
}

/**
* @param sound The sound that you want to be played to players
* @param loc Where the sound will be played
*/
public static void broadcastSound(Sound sound, Location loc) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.playSound(loc, sound, 1, 1);
}
}

/**
* @param sound The sound that you want to be played to players
* @param loc Where the sound will be played
* @param volume The volume that player will hear sound
*/
public static void broadcastSound(Sound sound, Location loc, int volume) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.playSound(loc, sound, volume, 1);
}
}



/**
* TODO: Test this function
* @param sound The sound that you want to be played to players
* @param source Where the sound will come from (for every player)
* @param distance The distance at the player will hear the sound (ignored if SoundSource.ONPLAYER)
* @param volume The volume that player will hear sound
*/
public static void broadcastSound(Sound sound, SoundSource source, int distance, int volume) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.playSound(source.getLocation(source, player.getLocation(), distance), sound, volume, 1);
}
}

public enum SoundSource {
BEHIND(),
FRONT(),
ONPLAYER();

/**
* Get location at a certain distance in the SoundSource direction
* @param type The sound that you want to be played to players
* @param source Where the sound will come from (for every player)
* @param distance The distance at the player will hear the sound (ignored if SoundSource.ONPLAYER)
* @return Location where sound will be played
*/
public static Location getLocation(SoundSource type, Location source, int distance) {
return type == BEHIND ? source.setDirection(source.getDirection().normalize().multiply(-distance)) :
type == FRONT ? source.setDirection(source.getDirection().normalize().multiply(distance)) :
type == ONPLAYER ? source :
null;
}
}
}

0 comments on commit 2c0b881

Please sign in to comment.