From 4edc486e4b66279deb0016bd69e59e7544c04565 Mon Sep 17 00:00:00 2001 From: Chip <65827213+ChipmunkMC@users.noreply.github.com> Date: Fri, 17 Feb 2023 21:24:36 -0500 Subject: [PATCH] Improve support for the queue --- .../chipmunkbot/commands/MusicCommand.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java index 5bdedd0..315f637 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java @@ -38,6 +38,7 @@ public class MusicCommand extends Command { ) .then(literal("stop").executes(this::stop)) + .then(literal("skip").executes(this::skip)) .then(literal("pause").executes(this::pause)) .then(literal("list").executes(this::list)) @@ -74,7 +75,20 @@ public class MusicCommand extends Command { if (songPlayer.currentSong() == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create(); songPlayer.stopPlaying(); - source.sendOutput(Component.translatable("Stopped playing the current song", NamedTextColor.GREEN)); + songPlayer.songQueue().clear(); + source.sendOutput(Component.translatable("Stopped music playback", NamedTextColor.GREEN)); + + return 1; + } + + public int skip (CommandContext context) throws CommandSyntaxException { + final CommandSource source = context.getSource(); + final SongPlayer songPlayer = source.client().songPlayer(); + + if (songPlayer.currentSong() == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create(); + + songPlayer.stopPlaying(); + source.sendOutput(Component.translatable("Skipped the current song", NamedTextColor.GREEN)); return 1; }