a note instrument thingy

This commit is contained in:
Chayapak 2023-08-12 20:34:06 +07:00
parent e5f3c74852
commit 6167af7340
2 changed files with 22 additions and 1 deletions

View file

@ -44,6 +44,7 @@ public class MusicCommand extends Command {
"goto <timestamp>", "goto <timestamp>",
"pitch <pitch>", "pitch <pitch>",
"speed <speed>", "speed <speed>",
"noteinstrument <instrument>",
"pause", "pause",
"resume", "resume",
"info" "info"
@ -76,6 +77,7 @@ public class MusicCommand extends Command {
case "goto" -> goTo(context, args); case "goto" -> goTo(context, args);
case "pitch" -> pitch(context, args); case "pitch" -> pitch(context, args);
case "speed" -> speed(context, args); case "speed" -> speed(context, args);
case "noteinstrument" -> noteInstrument(context, args);
case "pause", "resume" -> pause(context); case "pause", "resume" -> pause(context);
case "info" -> info(context); case "info" -> info(context);
default -> Component.text("Invalid action").color(NamedTextColor.RED); default -> Component.text("Invalid action").color(NamedTextColor.RED);
@ -367,6 +369,23 @@ public class MusicCommand extends Command {
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)); .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) { public Component pause (CommandContext context) {
final Bot bot = context.bot; final Bot bot = context.bot;
final Song currentSong = bot.music.currentSong; final Song currentSong = bot.music.currentSong;

View file

@ -48,6 +48,8 @@ public class MusicPlayerPlugin extends Bot.Listener {
public float pitch = 0; public float pitch = 0;
public float speed = 1; public float speed = 1;
public String instrument = "off";
private int ticksUntilPausedBossbar = 20; private int ticksUntilPausedBossbar = 20;
private int notesPerSecond = 0; private int notesPerSecond = 0;
@ -317,7 +319,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
"minecraft:execute as " + "minecraft:execute as " +
SELECTOR + SELECTOR +
" at @s run playsound " + " at @s run playsound " +
note.instrument.sound + (!instrument.equals("off") ? instrument : note.instrument.sound) +
" record @s ^" + blockPosition + " ^ ^ " + " record @s ^" + blockPosition + " ^ ^ " +
note.volume + note.volume +
" " + " " +