@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) { if (endReason.mayStartNext) { if (manager.isRepeatQueue()) { if (audioTrackContainer == null) { // This should never be null since the container is set when we queue a // track, and this even should only be fired when an track has ended. throw new IllegalStateException("Music track has ended while the audio track container is NULL"); } queue.offer(new AudioTrackContainer(track.makeClone(), audioTrackContainer.getRequester())); } nextTrack(); } else if (endReason.equals(AudioTrackEndReason.FINISHED) && queue.isEmpty()) { if (manager.getLastActiveMessage() != null) { service.submit(() -> handleEndOfQueueWithLastActiveMessage(true)); } } }