From 29ca22101a7343d51aa6ea4352f2f52c68d0e58a Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 10 Apr 2025 11:14:49 +0700 Subject: [PATCH] feat: `*music volume` (finally lol) --- build-number.txt | 2 +- .../chomens_bot/commands/MusicCommand.java | 19 ++++++++++++++++++- .../plugins/MusicPlayerPlugin.java | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/build-number.txt b/build-number.txt index 07eea57c..0c52fc6d 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -2589 \ No newline at end of file +2591 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java index a573b528..44789a86 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java @@ -52,6 +52,7 @@ public class MusicCommand extends Command { "goto ", "pitch ", "speed ", + "volume ", "amplify ", "noteinstrument ", "pause", @@ -61,7 +62,7 @@ public class MusicCommand extends Command { new String[] { "song" }, TrustLevel.PUBLIC, false, - new ChatPacketType[]{ ChatPacketType.DISGUISED } + new ChatPacketType[] { ChatPacketType.DISGUISED } ); } @@ -84,6 +85,7 @@ public class MusicCommand extends Command { case "goto" -> goTo(context); case "pitch" -> pitch(context); case "speed" -> speed(context); + case "volume" -> volume(context); case "amplify" -> amplify(context); case "noteinstrument" -> noteInstrument(context); case "pause", "resume" -> pause(context); @@ -451,6 +453,21 @@ public class MusicCommand extends Command { .color(bot.colorPalette.defaultColor); } + public Component volume (final CommandContext context) throws CommandException { + context.checkOverloadArgs(2); + + final Bot bot = context.bot; + + final float volume = context.getFloat(true, false); + + bot.music.volume = volume; + + return Component.empty() + .append(Component.text("Set the volume modifier to ")) + .append(Component.text(volume).color(bot.colorPalette.number)) + .color(bot.colorPalette.defaultColor); + } + public Component amplify (final CommandContext context) throws CommandException { context.checkOverloadArgs(2); diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java index 0e163f7a..6c75dbdd 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java @@ -56,6 +56,7 @@ public class MusicPlayerPlugin extends Bot.Listener implements CorePlugin.Listen public float pitch = 0; public float speed = 1; + public float volume = 0; public int amplify = 1; public boolean rainbow = false; // nbs easter egg @@ -402,7 +403,7 @@ public class MusicPlayerPlugin extends Bot.Listener implements CorePlugin.Listen note.pitch != note.shiftedPitch || note.shiftedInstrument != note.instrument; - final double volume = note.volume; + final double volume = note.volume + this.volume; if (shouldCustomPitch) { bot.core.run(