Discussion in 'Plugin Development' started by OverDodo, Jun 23, 2017.
How can i use that Packet to play out an LEVEL_UP sound to only one player?
public void onCommand(Command cmd, CommandSender sender, String commandLabel, String args)
Player p = (Player) sender;
World w = player.getWorld();
Player t = player.getServer().getPlayer(args);
//Sound.ENDERMAN_TELEPORT is the sound. Just type in Sound. and it should give u a
//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);
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.
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!
@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.
whats with the "#"?
@OverDodo Before the # is the class, the part after the # is the methodname.
Separate names with a comma.