From 2d3f61b9879192e451b54571bc4a8225d713d687 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Fri, 31 Mar 2023 14:51:52 +0700 Subject: [PATCH] remove stuff add stuff --- .../chomens_bot/commands/CloopCommand.java | 27 +++++++++++++++-- .../chomens_bot/commands/MusicCommand.java | 29 ++++++++++++++++++- .../plugins/MusicPlayerPlugin.java | 9 +++--- .../chayapak/chomens_bot/song/Song.java | 2 +- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java index 94f140b..4100812 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/CloopCommand.java @@ -52,17 +52,40 @@ public class CloopCommand implements Command { } catch (IllegalArgumentException ignored) { return Component.text("Invalid index").color(NamedTextColor.RED); } - bot.cloop().add(interval, String.join(" ", Arrays.copyOfRange(args, 2, args.length))); + + final String command = String.join(" ", Arrays.copyOfRange(args, 2, args.length)); + + bot.cloop().add(interval, command); + + context.sendOutput( + Component.translatable( + "Added %s with interval %s to the cloops", + Component.text(command).color(NamedTextColor.AQUA), + Component.text(interval).color(NamedTextColor.GOLD) + ) + ); } case "remove" -> { try { final int index = Integer.parseInt(args[1]); bot.cloop().remove(index); + + context.sendOutput( + Component.translatable( + "Removed cloop %s", + Component.text(index).color(NamedTextColor.GOLD) + ) + ); } catch (IllegalArgumentException | NullPointerException ignored) { return Component.text("Invalid index").color(NamedTextColor.RED); } } - case "clear" -> bot.cloop().clear(); + case "clear" -> { + bot.cloop().clear(); + context.sendOutput( + Component.text("Cleared all cloops") + ); + } case "list" -> { final List cloopsComponent = new ArrayList<>(); 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 9a6c982..dc15cae 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 @@ -39,7 +39,8 @@ public class MusicCommand implements Command { usages.add("skip"); usages.add("nowplaying"); usages.add("queue"); - usages.add("goto"); + usages.add("goto "); + usages.add("pitch "); usages.add("pause"); usages.add("resume"); @@ -80,6 +81,9 @@ public class MusicCommand implements Command { case "goto" -> { return goTo(context, args); } + case "pitch" -> { + return pitch(context, args); + } case "pause", "resume" -> { return pause(context); } @@ -111,6 +115,8 @@ public class MusicCommand implements Command { final Bot bot = context.bot(); bot.music().stopPlaying(); bot.music().songQueue().clear(); + + context.sendOutput(Component.text("Cleared the song queue")); } public Component loop (CommandContext context, String[] args) { @@ -252,6 +258,27 @@ public class MusicCommand implements Command { return Component.text("success"); } + public Component pitch (CommandContext context, String[] args) { + final Bot bot = context.bot(); + + float pitch; + try { + pitch = Float.parseFloat(args[1]); + } catch (IllegalArgumentException ignored) { + return Component.text("Invalid pitch").color(NamedTextColor.RED); + } + + bot.music().pitch(pitch); + + context.sendOutput( + Component.empty() + .append(Component.text("Set the pitch to ")) + .append(Component.text(pitch).color(NamedTextColor.GOLD)) + ); + + return Component.text("success"); + } + 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 1d9670d..90c06c2 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 @@ -37,7 +37,8 @@ public class MusicPlayerPlugin extends SessionAdapter { @Getter @Setter private SongLoaderThread loaderThread; @Getter @Setter private Loop loop = Loop.OFF; - @Getter @Setter private boolean nightcore = false; // don't tell anyone plz..,,.,. + // sus nightcore stuff,..,.,. + @Getter @Setter private float pitch = 0; private int ticksUntilPausedBossbar = 20; private final String bossbarName = "chomens_bot:music"; // maybe make this in the config? @@ -111,7 +112,7 @@ public class MusicPlayerPlugin extends SessionAdapter { bot.core().run("minecraft:bossbar add " + bossbarName + " \"\""); bot.core().run("minecraft:bossbar set " + bossbarName + " players " + SELECTOR); bot.core().run("minecraft:bossbar set " + bossbarName + " name " + GsonComponentSerializer.gson().serialize(generateBossbar())); - bot.core().run("minecraft:bossbar set " + bossbarName + " color " + (nightcore ? "purple" : "yellow")); + bot.core().run("minecraft:bossbar set " + bossbarName + " color " + (pitch > 0 ? "purple" : "yellow")); bot.core().run("minecraft:bossbar set " + bossbarName + " visible true"); bot.core().run("minecraft:bossbar set " + bossbarName + " style progress"); bot.core().run("minecraft:bossbar set " + bossbarName + " value " + (int) Math.floor(currentSong.time)); @@ -175,7 +176,7 @@ public class MusicPlayerPlugin extends SessionAdapter { final DecimalFormat formatter = new DecimalFormat("#,###"); Component component = Component.empty() - .append(Component.empty().append(currentSong.name).color(nightcore ? NamedTextColor.LIGHT_PURPLE : NamedTextColor.GREEN)) + .append(Component.empty().append(currentSong.name).color(pitch > 0 ? NamedTextColor.LIGHT_PURPLE : NamedTextColor.GREEN)) .append(Component.text(" | ").color(NamedTextColor.DARK_GRAY)) .append(Component.translatable("%s / %s", formatTime(currentSong.time).color(NamedTextColor.GRAY), formatTime(currentSong.length).color(NamedTextColor.GRAY)).color(NamedTextColor.DARK_GRAY)) .append(Component.text(" | ").color(NamedTextColor.DARK_GRAY)) @@ -232,7 +233,7 @@ public class MusicPlayerPlugin extends SessionAdapter { while (currentSong.reachedNextNote()) { final Note note = currentSong.getNextNote(); - final double floatingPitch = NumberUtilities.clamp(Math.pow(2, ((nightcore ? note.pitch + 1 : note.pitch) - 12) / 12.0), 0, 2); + final double floatingPitch = NumberUtilities.clamp(Math.pow(2, ((note.pitch + (pitch / 10)) - 12) / 12.0), 0, 2); bot.core().run("minecraft:execute as " + SELECTOR + " at @s run playsound " + note.instrument.sound + " record @s ~ ~ ~ " + note.volume + " " + floatingPitch); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java index 0a03f49..4a17994 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java @@ -77,7 +77,7 @@ public class Song { public boolean reachedNextNote () { if (position < notes.size()) { - return notes.get(position).time <= (bot.music().nightcore() ? time - 8 : time); + return notes.get(position).time <= time; } else { if (finished() && bot.music().loop() != Loop.OFF) { if (position < notes.size()) {