refactor: remove convoluted TrackLoader and LoadableSongs abstraction
BREAKING CHANGE: removed TrackLoader amd LoadableSongs
This commit is contained in:
1 parent
0db751af44
commit
2aa75ce0fc
10 files changed
+9
-385
No files matched your search
@@ -19,7 +19,6 @@ import me.bobert.netneutrality.core.LogHandler;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.db.GSettings;
|
||||
import me.bobert.netneutrality.exceptions.CommandExecutionException;
|
||||
import me.bobert.netneutrality.music.loadable.LoadableSong;
|
||||
import me.bobert.netneutrality.music.source.UdioAudioSourceManager;
|
||||
import me.bobert.netneutrality.thread.MusicPlayerAutoDisconnectThread;
|
||||
import me.bobert.netneutrality.thread.ThreadManager;
|
||||
@@ -30,8 +29,6 @@ import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -48,7 +45,6 @@ public class MusicManager {
|
||||
private final Guild guild;
|
||||
private final AudioPlayer player;
|
||||
private final TrackScheduler scheduler;
|
||||
private TrackLoader lastTrackLoader;
|
||||
private ScheduledFuture<?> autoDisconnectThread;
|
||||
private final int baseVolume;
|
||||
|
||||
@@ -126,10 +122,6 @@ public class MusicManager {
|
||||
return guild;
|
||||
}
|
||||
|
||||
public void stopLoading() {
|
||||
lastTrackLoader.stopLoading();
|
||||
}
|
||||
|
||||
public synchronized void leave() {
|
||||
if (guild != null && guild.getAudioManager().getConnectedChannel() != null) {
|
||||
logger.debug("Guild {}: leaving voice channel {}", guild.getId(), guild.getAudioManager().getConnectedChannel().getId());
|
||||
@@ -152,16 +144,9 @@ public class MusicManager {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void play(String url, CommandContext context, boolean needToBeConnected, boolean silent) {
|
||||
logger.debug("Guild {}: request to play '{}' by user {}", guild.getId(), url, context.getGuildUser().getId());
|
||||
public synchronized void play(String query, CommandContext context, boolean needToBeConnected, boolean silent) {
|
||||
logger.debug("Guild {}: request to play '{}' by user {}", guild.getId(), query, context.getGuildUser().getId());
|
||||
|
||||
List<LoadableSong> toLoad = new ArrayList<>();
|
||||
toLoad.add(new LoadableSong(null, url, null));
|
||||
|
||||
play(toLoad, context, needToBeConnected, silent);
|
||||
}
|
||||
|
||||
public void play(List<LoadableSong> songs, CommandContext context, boolean needToBeConnected, boolean silent) {
|
||||
Member member = context.getGuildUser();
|
||||
MessageChannel channel = context.getChannel();
|
||||
|
||||
@@ -189,10 +174,14 @@ public class MusicManager {
|
||||
scheduler.attachTextChannel(channel);
|
||||
}
|
||||
|
||||
TrackLoader loader = new TrackLoader(this, context, playerManager, silent);
|
||||
lastTrackLoader = loader;
|
||||
SourceFinder.AudioSourceType type = SourceFinder.getSource(query);
|
||||
String identifier = SourceFinder.getIdentifier(query);
|
||||
|
||||
loader.loadAllSongs(songs);
|
||||
if (identifier != null) {
|
||||
TrackLoadingHandler loadingHandler = new TrackLoadingHandler(context, this, identifier, type, silent);
|
||||
|
||||
playerManager.loadItemOrdered(this, identifier, loadingHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopTrack() {
|
||||
|
||||
Reference in new issue
Block a user