Class Music

java.lang.Object
com.marcusslover.plus.lib.sound.Music
All Implemented Interfaces:
ISendable<Music>

public class Music extends Object implements ISendable<Music>
Music can be used to loop notes for an audience or command sender.

Example:

     
     Music.of(Note.of(Key.key("music.loop"), 0.2f, 1f), 2400).send(audience);
     
 
This will play the note "music.loop" for 2400 ticks (2 minutes) for the audience.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Note
    The intro note to play before the loop.
    protected long
    The length of the intro in ticks.
    protected Note
    The note to play on loop.
    protected long
    The length of the loop in ticks.
    protected final Map<net.kyori.adventure.audience.Audience,Music.Session>
     
    protected Note
    The note to play when stopped.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    forceStop(net.kyori.adventure.audience.Audience audience)
    Stop the music from the audience without playing the tail.
    void
     
    @NotNull Music
    intro(@NotNull Note intro, long introLength)
    Set the intro note and length.
    @NotNull Music
    loop(@NotNull Note loop, long loopLength)
    Set the loop note and length.
    static @NotNull Music
    of(@NotNull Note intro, long introLength, @NotNull Note loop, long loopLength, @NotNull Note tail, @NotNull net.kyori.adventure.audience.Audience audience)
    Create a new music object with an intro and tail note.
    static @NotNull Music
    of(@NotNull Note note, long noteLength, @NotNull net.kyori.adventure.audience.Audience audience)
    Creates a new music object.
    void
    play(net.kyori.adventure.audience.Audience audience)
     
     
    @NotNull Music
    send(net.kyori.adventure.audience.Audience audience)
     
    <T extends org.bukkit.command.CommandSender>
    @NotNull Music
    send(T target)
     
    void
    Stop the music for an audience and play the tail if it exists.
    void
    stop(net.kyori.adventure.audience.Audience audience)
     
    void
     
    @NotNull Music
    tail(@NotNull Note tail)
    Set the tail note and length.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.marcusslover.plus.lib.common.ISendable

    send, send, sendAll, sendAll, sendAll
  • Field Details

    • sessions

      protected final Map<net.kyori.adventure.audience.Audience,Music.Session> sessions
    • intro

      protected Note intro
      The intro note to play before the loop.
    • introLength

      protected long introLength
      The length of the intro in ticks.
    • loop

      protected Note loop
      The note to play on loop.
    • loopLength

      protected long loopLength
      The length of the loop in ticks.
    • tail

      protected Note tail
      The note to play when stopped.
  • Method Details

    • of

      @NotNull public static @NotNull Music of(@NotNull @NotNull Note note, long noteLength, @NotNull @NotNull net.kyori.adventure.audience.Audience audience)
      Creates a new music object.
      Parameters:
      note - The note to play on loop.
      noteLength - The length of the note in ticks.
      Returns:
      The music object.
    • of

      @NotNull public static @NotNull Music of(@NotNull @NotNull Note intro, long introLength, @NotNull @NotNull Note loop, long loopLength, @NotNull @NotNull Note tail, @NotNull @NotNull net.kyori.adventure.audience.Audience audience)
      Create a new music object with an intro and tail note.
      Parameters:
      intro - Note to play before the loop.
      introLength - Length of the intro in ticks.
      loop - Note to play on loop.
      loopLength - Length of the loop in ticks.
      tail - Note to play when stopped.
      Returns:
      The music object.
    • stop

      public void stop(Music.Session session)
      Stop the music for an audience and play the tail if it exists.
      Parameters:
      session - The session that you would like to stop.
    • stop

      public void stop(net.kyori.adventure.audience.Audience audience)
    • stopAll

      public void stopAll()
    • forceStop

      public void forceStop(net.kyori.adventure.audience.Audience audience)
      Stop the music from the audience without playing the tail.
      Parameters:
      audience - The audience.
    • forceStopAll

      public void forceStopAll()
    • send

      @NotNull public <T extends org.bukkit.command.CommandSender> @NotNull Music send(@NotNull T target)
      Specified by:
      send in interface ISendable<Music>
    • send

      @NotNull public @NotNull Music send(net.kyori.adventure.audience.Audience audience)
      Specified by:
      send in interface ISendable<Music>
    • intro

      @NotNull public @NotNull Music intro(@NotNull @NotNull Note intro, long introLength)
      Set the intro note and length.
      Parameters:
      intro - Note to play before the loop.
      introLength - Length of the intro in ticks.
      Returns:
      The music object.
    • loop

      @NotNull public @NotNull Music loop(@NotNull @NotNull Note loop, long loopLength)
      Set the loop note and length.
      Parameters:
      loop - Note to play on loop.
      loopLength - Length of the loop in ticks.
      Returns:
      The music object.
    • tail

      @NotNull public @NotNull Music tail(@NotNull @NotNull Note tail)
      Set the tail note and length.
      Parameters:
      tail - Note to play when stopped.
      Returns:
      The music object.
    • playAllSessions

      public Music playAllSessions()
    • play

      public void play(net.kyori.adventure.audience.Audience audience)