}elseif(loop!=null&&loop.equals("autoplay")){//i dont think this is needed as people need to play something before autoplay can be toggled anyways
queueAutoplay(track);
}
}
publicvoidnextTrack(){//DONE rewrite to not include q.remove here so that stuff like interrupted wont break the queue?
AudioTracktrack=queue.poll();
player.startTrack(track,false);
if(track==null){
//System.out.println("finished"); //debug
loop=null;//reset loop and autoplay tracking
delayCloseConnection(player);//required because if not it will throw InterruptedException
}
}//externally called from AudioTrackHandler.skipTrack()
publicvoidqueueAutoplay(AudioTracktrack){//DONE check duplicate please, some can get into a dead loop like cosMo@暴走P - WalpurgisNacht and Ice - 絶 //using yt tracking params now; still can get into loops but random should fix
ap.ex.submit(()->{//async so it can free up the event
Memberuser=guild.getMemberById(DiscordBot.BotID);//no need to use original track user as it would introduce performance overhead and other complications when leaving channels
ap.load(user,url,(n,l)->{
AudioTrackauto=l.get(0);
auto.setUserData(newTrackData(auto.getInfo().uri,auto.getDuration(),autoplay.toString()));//set new tracking
ap.queueTracks(l,user);//no need sublist coz l is always a single video
},ex->{
ex.printStackTrace();
DiscordBot.lastMusicCmd.get(guild.getId()).sendMessage("Something went wrong when loading next autoplay track: "+ex.getMessage()).queue();
loop=null;
});
}catch(Exceptione){
e.printStackTrace();
DiscordBot.lastMusicCmd.get(guild.getId()).sendMessage("Something went wrong when loading next autoplay track. Is the last track a youtube video?").queue();