diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..f610ed7fc Binary files /dev/null and b/.DS_Store differ diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 000000000..fccf79702 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 69248fc88..5d097e238 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -124,6 +124,7 @@ private static void startBot() new PauseCmd(bot), new PlaynextCmd(bot), new RepeatCmd(bot), + new ShuffleAllCmd(bot), new SkiptoCmd(bot), new StopCmd(bot), new VolumeCmd(bot), diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ShuffleAllCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ShuffleAllCmd.java new file mode 100644 index 000000000..80dba3916 --- /dev/null +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ShuffleAllCmd.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019 John Grosh . + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.jagrosh.jmusicbot.commands.dj; + +import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.audio.AudioHandler; +import com.jagrosh.jmusicbot.commands.DJCommand; + +/** + * + * @author Joshua L. + */ +public class ShuffleAllCmd extends DJCommand +{ + public ShuffleAllCmd(Bot bot) + { + super(bot); + this.name = "shuffleall"; + this.help = "shuffles all songs in the queue"; + this.aliases = bot.getConfig().getAliases(this.name); + this.bePlaying = true; + } + + @Override + public void doCommand(CommandEvent event) + { + AudioHandler handler = (AudioHandler)event.getGuild().getAudioManager().getSendingHandler(); + int s = handler.getQueue().shuffle(0, true); + switch (s) + { + case 0: + event.replyError("There isn't any music in the queue to shuffle!"); + break; + case 1: + event.replyWarning("There is only one song in the queue!"); + break; + default: + event.replySuccess("You successfully shuffled "+s+" entries."); + break; + } + } +} diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java index c151f4d83..ee087c657 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java @@ -40,7 +40,7 @@ public ShuffleCmd(Bot bot) public void doCommand(CommandEvent event) { AudioHandler handler = (AudioHandler)event.getGuild().getAudioManager().getSendingHandler(); - int s = handler.getQueue().shuffle(event.getAuthor().getIdLong()); + int s = handler.getQueue().shuffle(event.getAuthor().getIdLong(), false); switch (s) { case 0: diff --git a/src/main/java/com/jagrosh/jmusicbot/queue/FairQueue.java b/src/main/java/com/jagrosh/jmusicbot/queue/FairQueue.java index 66106178a..c356a5379 100644 --- a/src/main/java/com/jagrosh/jmusicbot/queue/FairQueue.java +++ b/src/main/java/com/jagrosh/jmusicbot/queue/FairQueue.java @@ -104,15 +104,26 @@ public void clear() list.clear(); } - public int shuffle(long identifier) + public int shuffle(long identifier, Boolean shuffleall) { List iset = new ArrayList<>(); - for(int i=0; i