Solved Play sound to just 1 person

Discussion in 'Plugin Development' started by YoFuzzy3, Dec 12, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    YoFuzzy3

    I'm wanting to play a sound to just 1 person, how would I do this? If I play a sound at a player's location with this code it can still be heard within roughly 16 blocks.
    Code:java
    1. @EventHandler(priority = EventPriority.MONITOR)
    2. public void onEntityDamageByEntity(EntityDamageByEntityEvent event){
    3. if(event.getDamager() instanceof Arrow){
    4. Arrow arrow = (Arrow) event.getDamager();
    5. if(arrow.getShooter() instanceof Player){
    6. Player player = (Player) arrow.getShooter();
    7. Location loc = player.getLocation();
    8. World world = loc.getWorld();
    9. world.playSound(loc, Sound.ORB_PICKUP, 1, 0);
    10. }
    11. }
    12. }
     
  2. So play the sound on the world, why not try to play it on the player instead (player.playSound()) ? ;)
     
  3. Offline

    YoFuzzy3

    Didn't even know that existed, thanks. :)
     
Thread Status:
Not open for further replies.

Share This Page