From 6167af7340584134b538f5e353101e1a1d46ee55 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 12 Aug 2023 20:34:06 +0700 Subject: [PATCH] a note instrument thingy --- .../chomens_bot/commands/MusicCommand.java | 19 +++++++++++++++++++ .../plugins/MusicPlayerPlugin.java | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java index 7ecd7a6..c601063 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java @@ -44,6 +44,7 @@ public class MusicCommand extends Command { "goto ", "pitch ", "speed ", + "noteinstrument ", "pause", "resume", "info" @@ -76,6 +77,7 @@ public class MusicCommand extends Command { case "goto" -> goTo(context, args); case "pitch" -> pitch(context, args); case "speed" -> speed(context, args); + case "noteinstrument" -> noteInstrument(context, args); case "pause", "resume" -> pause(context); case "info" -> info(context); default -> Component.text("Invalid action").color(NamedTextColor.RED); @@ -367,6 +369,23 @@ public class MusicCommand extends Command { .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); } + public Component noteInstrument (CommandContext context, String[] args) { + final Bot bot = context.bot; + + final String instrument = args[1]; + + bot.music.instrument = instrument; + + if (!instrument.equals("off")) { + return Component.empty() + .append(Component.text("Set the instrument for every note to ")) + .append(Component.text(instrument).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))) + .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + } else { + return Component.text("Every notes are now using its instrument").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); + } + } + public Component pause (CommandContext context) { final Bot bot = context.bot; final Song currentSong = bot.music.currentSong; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java index 469d1a0..f0684b9 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java @@ -48,6 +48,8 @@ public class MusicPlayerPlugin extends Bot.Listener { public float pitch = 0; public float speed = 1; + public String instrument = "off"; + private int ticksUntilPausedBossbar = 20; private int notesPerSecond = 0; @@ -317,7 +319,7 @@ public class MusicPlayerPlugin extends Bot.Listener { "minecraft:execute as " + SELECTOR + " at @s run playsound " + - note.instrument.sound + + (!instrument.equals("off") ? instrument : note.instrument.sound) + " record @s ^" + blockPosition + " ^ ^ " + note.volume + " " +