Cancelling an already sent sound packet

Discussion in 'Plugin Development' started by jl97, Mar 23, 2014.

Thread Status:
Not open for further replies.
  1. Hi, i have this piece of code where i send a specific player the PacketPlayOutNamedSoundEffect packet. Now say, i send a packet telling the client to play a specific music disc, and after a few seconds I want to make the client stop playing it, so that i can for instance, make it play another music disc. Is this possible? And if it is, how?

    Code:java
    1. @Override
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    3. if(args[0].equalsIgnoreCase("sound")) {
    4. Player player = (Player) sender;
    5. PacketPlayOutNamedSoundEffect p = new PacketPlayOutNamedSoundEffect(args[1], 0, 0, 0, Float.MAX_VALUE, 1);
    6. ((CraftPlayer)player).getHandle().playerConnection.sendPacket(p);
    7. return true;
    8. }
    9. return false;
    10. }
     
  2. Offline

    acecheesecr14

    jl97 I don't think that's possible :S
     
  3. Offline

    xJeremyCx

  4. Thank you ^^ that could be usefull.
    I haven't found a cancel sound after it already has been sent option though :/
     
  5. Offline

    Garris0n

    You can just use player.playEffect, you don't need packets for this. If you pass it null instead of a material for the music disk it stops. For the packet, send it 0 for the disk ID.
     
    jl97 likes this.
  6. Garris0n
    That's it! Thank you!
    (Pardon me for the late response, i didn't expect anymore answers.)
     
Thread Status:
Not open for further replies.

Share This Page