(A tester)
Refonte complète du système de jukebox et de menu.
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.Skydust.JdrBot.cmds.playmusic;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack;
|
||||||
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
@@ -23,7 +24,9 @@ import fr.Skydust.JdrBot.audio.GuildMusicManager;
|
|||||||
public class PlayMusic extends Command {
|
public class PlayMusic extends Command {
|
||||||
private static final AudioPlayerManager playerManager = new DefaultAudioPlayerManager();
|
private static final AudioPlayerManager playerManager = new DefaultAudioPlayerManager();
|
||||||
static Map<Long, GuildMusicManager> musicManagers;
|
static Map<Long, GuildMusicManager> musicManagers;
|
||||||
|
|
||||||
|
public static Map<Long, JukeboxSystem> jukeboxSystems;
|
||||||
|
|
||||||
public PlayMusic() {
|
public PlayMusic() {
|
||||||
musicManagers = new HashMap<>();
|
musicManagers = new HashMap<>();
|
||||||
AudioSourceManagers.registerRemoteSources(playerManager);
|
AudioSourceManagers.registerRemoteSources(playerManager);
|
||||||
@@ -39,17 +42,22 @@ public class PlayMusic extends Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: MAKE SURE ONLY ONE JUKEBOX PER GUILD
|
if(getGuildsJukebox(e.getGuild()) != null) {
|
||||||
if(JukeboxGUISystem.getGuildsJukebox(e.getGuild()) != null) {
|
|
||||||
e.getChannel().sendMessage("/!\\ Le lecteur audio est deja present ici ! Pour l'arreter, tapez \"!stopmusic\" !").queue();
|
e.getChannel().sendMessage("/!\\ Le lecteur audio est deja present ici ! Pour l'arreter, tapez \"!stopmusic\" !").queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//TODO: WHILE LOADING, CAN CALL AGAIN
|
||||||
e.getChannel().sendMessage("Loading...").queue(JukeboxSystem::new);
|
// Creates a message to be edited by the jukebox system
|
||||||
|
e.getChannel().sendMessage("Loading...").queue(msg -> jukeboxSystems.put(e.getGuild().getIdLong(), new JukeboxSystem(msg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JukeboxSystem getGuildsJukebox(Guild guild) {
|
||||||
|
return jukeboxSystems.get(guild.getIdLong());
|
||||||
|
}
|
||||||
|
|
||||||
public static void loadAndPlay(final TextChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
|
public static void loadAndPlay(final TextChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
|
||||||
System.out.println(trackUrl);
|
System.out.println(trackUrl);
|
||||||
|
|
||||||
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
|
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
|
||||||
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
|
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package fr.Skydust.JdrBot.cmds.playmusic;
|
package fr.Skydust.JdrBot.cmds.playmusic;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.cmds.record.Record;
|
import fr.Skydust.JdrBot.cmds.record.Record;
|
||||||
|
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
@@ -36,14 +37,14 @@ public class StopMusic extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void stopMusic(Guild g) {
|
public static void stopMusic(Guild g) {
|
||||||
JukeboxGUI gui = JukeboxGUISystem.getGuildsJukebox(g);
|
JukeboxSystem jukebox = PlayMusic.getGuildsJukebox(g);
|
||||||
|
|
||||||
if(gui != null) {
|
if(jukebox != null) {
|
||||||
g.getTextChannelById(gui.TextChannelID).deleteMessageById(gui.MessageID)
|
jukebox.jukeboxMessage.delete().queue();
|
||||||
.queue(msg -> {
|
|
||||||
JukeboxGUISystem.setGuildsJukebox(g, null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayMusic.jukeboxSystems.put(g.getIdLong(), null);
|
||||||
|
|
||||||
PlayMusic.getGuildAudioPlayer(g).scheduler.stop();
|
PlayMusic.getGuildAudioPlayer(g).scheduler.stop();
|
||||||
|
|
||||||
if(!Record.getGuildRecordState(g).isRecording) {
|
if(!Record.getGuildRecordState(g).isRecording) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package fr.Skydust.JdrBot.cmds.record;
|
package fr.Skydust.JdrBot.cmds.record;
|
||||||
|
|
||||||
|
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import fr.Skydust.JdrBot.stock.RecordState;
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
import fr.Skydust.JdrBot.utils.MessageType;
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
@@ -16,7 +17,7 @@ public class CancelRecord extends Command {
|
|||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||||
if(rs.isRecording) {
|
if(rs.isRecording) {
|
||||||
if(JukeboxGUISystem.getGuildsJukebox(e.getGuild()) == null) {
|
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||||
e.getGuild().getAudioManager().closeAudioConnection();
|
e.getGuild().getAudioManager().closeAudioConnection();
|
||||||
}
|
}
|
||||||
rs.cancelRecord(e.getGuild());
|
rs.cancelRecord(e.getGuild());
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package fr.Skydust.JdrBot.cmds.record;
|
package fr.Skydust.JdrBot.cmds.record;
|
||||||
|
|
||||||
|
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import fr.Skydust.JdrBot.stock.RecordState;
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
import fr.Skydust.JdrBot.utils.MessageType;
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
@@ -16,7 +17,7 @@ public class StopRecord extends Command {
|
|||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||||
if(rs.isRecording) {
|
if(rs.isRecording) {
|
||||||
if(JukeboxGUISystem.getGuildsJukebox(e.getGuild()) == null) {
|
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||||
e.getGuild().getAudioManager().closeAudioConnection();
|
e.getGuild().getAudioManager().closeAudioConnection();
|
||||||
}
|
}
|
||||||
rs.endRecord(e.getGuild(), e.getChannel());
|
rs.endRecord(e.getGuild(), e.getChannel());
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import fr.Skydust.JdrBot.menu.Menu;
|
|||||||
import fr.Skydust.JdrBot.menu.MenuSystem;
|
import fr.Skydust.JdrBot.menu.MenuSystem;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -22,7 +21,7 @@ public class JukeboxSystem {
|
|||||||
public String songPlayedPath = "";
|
public String songPlayedPath = "";
|
||||||
|
|
||||||
private final HashMap<String, Menu> linkedPath = new HashMap<>();
|
private final HashMap<String, Menu> linkedPath = new HashMap<>();
|
||||||
private final Message jukeboxMessage;
|
public final Message jukeboxMessage;
|
||||||
|
|
||||||
private String currentFolder = "";
|
private String currentFolder = "";
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public class Utils {
|
|||||||
public static final String FolderUnicode = "\uD83D\uDCC1";
|
public static final String FolderUnicode = "\uD83D\uDCC1";
|
||||||
public static final String ReturnUnicode = "\u21A9";
|
public static final String ReturnUnicode = "\u21A9";
|
||||||
|
|
||||||
|
public static final String ProgressBarForeground = "\uD83D\uDFE9";
|
||||||
|
public static final String ProgressBarBackground = "\u2B1C";
|
||||||
|
|
||||||
public static boolean IsInt(String info) {
|
public static boolean IsInt(String info) {
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(info);
|
Integer.parseInt(info);
|
||||||
|
|||||||
Reference in New Issue
Block a user