Correct double autoflow
This commit is contained in:
parent
073fedb6d1
commit
23ae030924
@ -87,8 +87,11 @@ public class TrackScheduler extends AudioEventAdapter {
|
|||||||
currentPlayingTrack = track;
|
currentPlayingTrack = track;
|
||||||
}
|
}
|
||||||
if(track.getSubmittedUser() != MainBot.jda.getSelfUser()) {
|
if(track.getSubmittedUser() != MainBot.jda.getSelfUser()) {
|
||||||
|
|
||||||
needAutoPlay();
|
needAutoPlay();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
logger.debug("Bot add, ignore autoFlow");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause() {
|
public void pause() {
|
||||||
@ -166,19 +169,19 @@ public class TrackScheduler extends AudioEventAdapter {
|
|||||||
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
|
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
|
||||||
// Only start the next track if the end reason is suitable for it (FINISHED or LOAD_FAILED)
|
// Only start the next track if the end reason is suitable for it (FINISHED or LOAD_FAILED)
|
||||||
if (endReason.mayStartNext) {
|
if (endReason.mayStartNext) {
|
||||||
|
logger.debug("End of track, start next.");
|
||||||
nextTrack();
|
nextTrack();
|
||||||
needAutoPlay();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void needAutoPlay(){
|
private void needAutoPlay(){
|
||||||
if((queue.size() < 1) && autoFlow && currentPlayingTrack != null){
|
if((queue.size() < 1) && autoFlow && currentPlayingTrack != null){
|
||||||
logger.info("Auto add needed!");
|
logger.debug("Auto add needed!");
|
||||||
AudioM audioM = AudioM.getInstance(null);
|
AudioM audioM = AudioM.getInstance(null);
|
||||||
YoutubeTools youtubeTools = YoutubeTools.getInstance(null);
|
YoutubeTools youtubeTools = YoutubeTools.getInstance(null);
|
||||||
try {
|
try {
|
||||||
String id = youtubeTools.getRelatedVideo(currentPlayingTrack.getAudioTrack().getInfo().identifier, history);
|
String id = youtubeTools.getRelatedVideo(currentPlayingTrack.getAudioTrack().getInfo().identifier, history);
|
||||||
logger.info("Related id: "+id);
|
logger.debug("Related id: "+id);
|
||||||
audioM.loadAndPlayAuto(id);
|
audioM.loadAndPlayAuto(id);
|
||||||
|
|
||||||
} catch (GoogleJsonResponseException e) {
|
} catch (GoogleJsonResponseException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user