diff --git a/pom.xml b/pom.xml
index cc98129..482faaf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.andrewlalis
HandieBot
- 1.5.2
+ 1.5.3
diff --git a/src/main/java/handiebot/command/commands/music/QueueCommand.java b/src/main/java/handiebot/command/commands/music/QueueCommand.java
index 36cbd1d..56da85c 100644
--- a/src/main/java/handiebot/command/commands/music/QueueCommand.java
+++ b/src/main/java/handiebot/command/commands/music/QueueCommand.java
@@ -5,6 +5,7 @@ import handiebot.command.CommandContext;
import handiebot.command.Commands;
import handiebot.command.types.ContextCommand;
import handiebot.lavaplayer.playlist.Playlist;
+import handiebot.lavaplayer.playlist.UnloadedTrack;
import handiebot.view.BotLog;
import java.text.MessageFormat;
@@ -24,12 +25,13 @@ public class QueueCommand extends ContextCommand {
public QueueCommand() {
super("queue",
- "[all|clear|save|remove]",
+ "[all|clear|save|remove|move]",
resourceBundle.getString("commands.command.queue.description.main")+"\n" +
"\t`all` - "+resourceBundle.getString("commands.command.queue.description.all")+"\n" +
"\t`clear` - "+resourceBundle.getString("commands.command.queue.description.clear")+"\n" +
"\t`save ` - "+resourceBundle.getString("commands.command.queue.description.save")+"\n"+
- "\t`remove ` - "+resourceBundle.getString("commands.command.queue.description.remove"),
+ "\t`remove ` - "+resourceBundle.getString("commands.command.queue.description.remove")+"\n"+
+ "\t`move - "+resourceBundle.getString("commands.command.queue.description.move"),
0);
}
@@ -72,6 +74,24 @@ public class QueueCommand extends ContextCommand {
} else {
sendMessage(resourceBundle.getString("commands.command.queue.remove.error"), context.getChannel());
}
+ case ("move"):
+ if (context.getArgs().length == 3 && Commands.hasPermission(context, 8)){
+ int startIndex = Integer.parseInt(context.getArgs()[1]);
+ int newIndex = Integer.parseInt(context.getArgs()[2]);
+ Playlist playlist = HandieBot.musicPlayer.getMusicManager(context.getGuild()).scheduler.getActivePlaylist();
+ int trackCount = playlist.getTrackCount();
+ //Test if the indices are valid, and if not, show an error message.
+ if ((startIndex > 0) && (startIndex <= trackCount) && (newIndex > 0) && (newIndex <= trackCount)){
+ List tracks = playlist.getTracks();
+ UnloadedTrack track = tracks.remove(startIndex-1);
+ tracks.add(newIndex-1, track);
+ sendMessage(MessageFormat.format(resourceBundle.getString("commands.command.queue.move.success"), track.getTitle(), startIndex, newIndex), context.getChannel());
+ } else {
+ sendMessage(resourceBundle.getString("commands.command.queue.move.indexError"), context.getChannel());
+ }
+ } else {
+ sendMessage(resourceBundle.getString("commands.command.queue.move.error"), context.getChannel());
+ }
}
} else {
HandieBot.musicPlayer.showQueueList(context.getGuild(), false);
diff --git a/src/main/resources/Strings.properties b/src/main/resources/Strings.properties
index a848181..2180a0e 100644
--- a/src/main/resources/Strings.properties
+++ b/src/main/resources/Strings.properties
@@ -96,12 +96,16 @@ commands.command.queue.description.all=Shows all songs.
commands.command.queue.description.clear=Clears the queue and stops playing.
commands.command.queue.description.save=Saves the queue to a playlist.
commands.command.queue.description.remove=Removes a song from the queue.
+commands.command.queue.description.move=Moves a song from one index to another.
commands.command.queue.clear=Cleared queue.
commands.command.queue.save.message=Saved {0} tracks to playlist **{1}**.
commands.command.queue.save.log=Saved queue to playlist [{0}].
commands.command.queue.error.save=Unable to save the queue to a playlist.
commands.command.queue.remove.message=Removed song(s) from the active queue.
commands.command.queue.remove.error=You must give the index of a song to remove from the queue.
+commands.command.queue.move.error=You must give the original index of a song in the queue, and a new index.
+commands.command.queue.move.indexError=The indices you entered are invalid.
+commands.command.queue.move.success=Moved song *{0}* from position {1} to position {2}.
#Repeat
commands.command.repeat.description=Sets repeating.
#Shuffle
diff --git a/src/main/resources/Strings_nl.properties b/src/main/resources/Strings_nl.properties
index 1126c85..20250ef 100644
--- a/src/main/resources/Strings_nl.properties
+++ b/src/main/resources/Strings_nl.properties
@@ -133,5 +133,6 @@ commands.command.report.description=Reports a user to administrators.
commands.command.report.error=You must name a user in your report.
commands.command.queue.remove=Removed song(s) from the active queue.
commands.command.queue.remove.error=You must give the index of a song to remove from the queue.
+commands.command.queue.move.success=Moved song *{0}* from position {1} to position {2}.