Solved Cancelling a playEffect

Discussion in 'Plugin Development' started by blue1, Jan 30, 2016.

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

    blue1

    I made a simple plugin that plays a music disc when a player types a command. I want to know, though, if there is any way to test if there is already one playing and how to cancel it, or if there is a way to only play it while something else is also present, for instance if player.isOnline or something like that. I can post my code if it is needed.
     
  2. Offline

    Coopah

    @blue1
    How are you playing the sound? Repeating task etc? You could add the player to an ArrayList when they first play a music disc and then when they are going to play another, you could simple check if the ArrayList contains the player.

    Make sure to store their names and not their whole player files, also don't forget to remove them when necessary.
     
    blue1 likes this.
  3. Offline

    blue1

    I am simply doing a p.getWorld().playEffect and setting that to a music disc. I'll try the arrayList, thanks. :D
     
  4. Offline

    blue1

    @Coopah
    The ArrayList works wonderfully, when combined with a bukkitRunnable that is delayed for the length of the song! Thank you for your help. It became exactly what I wanted. :D
     
  5. Offline

    Coopah

Thread Status:
Not open for further replies.

Share This Page