Add back support for restarting the current track.

jda-v5
Nekojimi 2 years ago
parent 4e654d2d18
commit ae7fe8cc7b
  1. 17
      src/main/java/moe/nekojimi/chords/QueueManager.java

@ -26,6 +26,8 @@ import java.util.function.Consumer;
*/ */
public class QueueManager implements Consumer<Song> public class QueueManager implements Consumer<Song>
{ {
private Song restartingSong = null;
private final Queue<Song> jukeboxQueue; private final Queue<Song> jukeboxQueue;
private Playlist playlist; private Playlist playlist;
private MusicHandler handler; private MusicHandler handler;
@ -52,6 +54,13 @@ public class QueueManager implements Consumer<Song>
*/ */
public Song nextSongNeeded() public Song nextSongNeeded()
{ {
// if we're restarting the current song: store, clear, and return it
if (restartingSong != null)
{
Song ret = restartingSong;
restartingSong = null;
return ret;
}
// if there's anything in the queue, play that first // if there's anything in the queue, play that first
if (!jukeboxQueue.isEmpty()) if (!jukeboxQueue.isEmpty())
{ {
@ -118,6 +127,12 @@ public class QueueManager implements Consumer<Song>
public boolean restartSong() public boolean restartSong()
{ {
throw new UnsupportedOperationException("Not supported yet."); restartingSong = handler.getCurrentSong();
if (restartingSong != null)
{
handler.playNext();
return true;
} else
return false;
} }
} }

Loading…
Cancel
Save