2017-10-22 23:48:13 +02:00
|
|
|
package net.Broken.audio;
|
|
|
|
|
|
|
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
|
|
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
2018-04-26 11:16:47 +02:00
|
|
|
import net.dv8tion.jda.core.entities.Guild;
|
2017-10-22 23:48:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Holder for both the player and a track scheduler for one guild.
|
|
|
|
*/
|
|
|
|
public class GuildMusicManager {
|
|
|
|
/**
|
|
|
|
* Audio player for the guild.
|
|
|
|
*/
|
|
|
|
public final AudioPlayer player;
|
|
|
|
/**
|
|
|
|
* Track scheduler for the player.
|
|
|
|
*/
|
|
|
|
public final TrackScheduler scheduler;
|
|
|
|
|
2018-04-26 11:16:47 +02:00
|
|
|
public final Guild guild;
|
|
|
|
|
2017-10-22 23:48:13 +02:00
|
|
|
/**
|
|
|
|
* Creates a player and a track scheduler.
|
|
|
|
* @param manager Audio player manager to use for creating the player.
|
|
|
|
*/
|
2018-04-26 11:16:47 +02:00
|
|
|
public GuildMusicManager(AudioPlayerManager manager, Guild guild) {
|
2017-10-22 23:48:13 +02:00
|
|
|
player = manager.createPlayer();
|
2018-04-26 11:16:47 +02:00
|
|
|
scheduler = new TrackScheduler(player, guild);
|
2017-10-22 23:48:13 +02:00
|
|
|
player.addListener(scheduler);
|
2018-04-26 11:16:47 +02:00
|
|
|
this.guild = guild;
|
2017-10-22 23:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Wrapper around AudioPlayer to use it as an AudioSendHandler.
|
|
|
|
*/
|
|
|
|
public AudioPlayerSendHandler getSendHandler() {
|
|
|
|
return new AudioPlayerSendHandler(player);
|
|
|
|
}
|
|
|
|
}
|