PacketPlayOutNamedSoundEffect Help!

Discussion in 'Plugin Development' started by OverDodo, Jun 23, 2017.

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



    How can i use that Packet to play out an LEVEL_UP sound to only one player?
  2. public void onCommand(Command cmd, CommandSender sender, String commandLabel, String[] args)
    //command name
    if(commandLabel.equalsIgnoreCase(<Sound ID>))
    Player p = (Player) sender;
    World w = player.getWorld();
    Player t = player.getServer().getPlayer(args[0]);
    //Sound.ENDERMAN_TELEPORT is the sound. Just type in Sound. and it should give u a
    //on eclipse
    //player.getLocation() is where the sound will originate so make sure u put this after the teleport takes place.
    //or else no one would hear it
    //10 is the volume so this is loud enough to hear
    //1 is the pitch. i wouldnt change it.
    w.playSound(player.getLocation(), Sound.<Sound ID>, 10, 1);
  3. Offline


    Please do not spoonfeed. All you needed to do was link to the playsound method ,Not only that, but this is not what he asked for. He is asking to play the sound for one player, but you are using the world object, which plays the sound for all players.

    Just use Player#playSound(Location, Sound, Int(Volume), int(Pitch)). The pitch should be 1, and for max volume, it should be 10.
  4. Offline


    If you have a little bit of experience with Sounds, you should know, that players, who are near to that location can hear it too!
  5. Offline


    @OverDodo No, they can't. If you use player#playSound(); only the player you specified can hear the sound. The location is so that the sound can be played using stereo (or surround!) sound.
  6. Offline


    whats with the "#"?
  7. Offline

    timtower Administrator Administrator Moderator

    @OverDodo Before the # is the class, the part after the # is the methodname.
Thread Status:
Not open for further replies.

Share This Page