forked from ChomeNS/chomens-bot-java
remove stuff add stuff
This commit is contained in:
parent
91bae37d02
commit
2d3f61b987
4 changed files with 59 additions and 8 deletions
|
@ -52,17 +52,40 @@ public class CloopCommand implements Command {
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
return Component.text("Invalid index").color(NamedTextColor.RED);
|
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" -> {
|
case "remove" -> {
|
||||||
try {
|
try {
|
||||||
final int index = Integer.parseInt(args[1]);
|
final int index = Integer.parseInt(args[1]);
|
||||||
bot.cloop().remove(index);
|
bot.cloop().remove(index);
|
||||||
|
|
||||||
|
context.sendOutput(
|
||||||
|
Component.translatable(
|
||||||
|
"Removed cloop %s",
|
||||||
|
Component.text(index).color(NamedTextColor.GOLD)
|
||||||
|
)
|
||||||
|
);
|
||||||
} catch (IllegalArgumentException | NullPointerException ignored) {
|
} catch (IllegalArgumentException | NullPointerException ignored) {
|
||||||
return Component.text("Invalid index").color(NamedTextColor.RED);
|
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" -> {
|
case "list" -> {
|
||||||
final List<Component> cloopsComponent = new ArrayList<>();
|
final List<Component> cloopsComponent = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ public class MusicCommand implements Command {
|
||||||
usages.add("skip");
|
usages.add("skip");
|
||||||
usages.add("nowplaying");
|
usages.add("nowplaying");
|
||||||
usages.add("queue");
|
usages.add("queue");
|
||||||
usages.add("goto");
|
usages.add("goto <timestamp>");
|
||||||
|
usages.add("pitch <pitch>");
|
||||||
usages.add("pause");
|
usages.add("pause");
|
||||||
usages.add("resume");
|
usages.add("resume");
|
||||||
|
|
||||||
|
@ -80,6 +81,9 @@ public class MusicCommand implements Command {
|
||||||
case "goto" -> {
|
case "goto" -> {
|
||||||
return goTo(context, args);
|
return goTo(context, args);
|
||||||
}
|
}
|
||||||
|
case "pitch" -> {
|
||||||
|
return pitch(context, args);
|
||||||
|
}
|
||||||
case "pause", "resume" -> {
|
case "pause", "resume" -> {
|
||||||
return pause(context);
|
return pause(context);
|
||||||
}
|
}
|
||||||
|
@ -111,6 +115,8 @@ public class MusicCommand implements Command {
|
||||||
final Bot bot = context.bot();
|
final Bot bot = context.bot();
|
||||||
bot.music().stopPlaying();
|
bot.music().stopPlaying();
|
||||||
bot.music().songQueue().clear();
|
bot.music().songQueue().clear();
|
||||||
|
|
||||||
|
context.sendOutput(Component.text("Cleared the song queue"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component loop (CommandContext context, String[] args) {
|
public Component loop (CommandContext context, String[] args) {
|
||||||
|
@ -252,6 +258,27 @@ public class MusicCommand implements Command {
|
||||||
return Component.text("success");
|
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) {
|
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();
|
||||||
|
|
|
@ -37,7 +37,8 @@ public class MusicPlayerPlugin extends SessionAdapter {
|
||||||
@Getter @Setter private SongLoaderThread loaderThread;
|
@Getter @Setter private SongLoaderThread loaderThread;
|
||||||
@Getter @Setter private Loop loop = Loop.OFF;
|
@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 int ticksUntilPausedBossbar = 20;
|
||||||
private final String bossbarName = "chomens_bot:music"; // maybe make this in the config?
|
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 add " + bossbarName + " \"\"");
|
||||||
bot.core().run("minecraft:bossbar set " + bossbarName + " players " + SELECTOR);
|
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 + " 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 + " visible true");
|
||||||
bot.core().run("minecraft:bossbar set " + bossbarName + " style progress");
|
bot.core().run("minecraft:bossbar set " + bossbarName + " style progress");
|
||||||
bot.core().run("minecraft:bossbar set " + bossbarName + " value " + (int) Math.floor(currentSong.time));
|
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("#,###");
|
final DecimalFormat formatter = new DecimalFormat("#,###");
|
||||||
|
|
||||||
Component component = Component.empty()
|
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.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.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))
|
.append(Component.text(" | ").color(NamedTextColor.DARK_GRAY))
|
||||||
|
@ -232,7 +233,7 @@ public class MusicPlayerPlugin extends SessionAdapter {
|
||||||
while (currentSong.reachedNextNote()) {
|
while (currentSong.reachedNextNote()) {
|
||||||
final Note note = currentSong.getNextNote();
|
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);
|
bot.core().run("minecraft:execute as " + SELECTOR + " at @s run playsound " + note.instrument.sound + " record @s ~ ~ ~ " + note.volume + " " + floatingPitch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class Song {
|
||||||
|
|
||||||
public boolean reachedNextNote () {
|
public boolean reachedNextNote () {
|
||||||
if (position < notes.size()) {
|
if (position < notes.size()) {
|
||||||
return notes.get(position).time <= (bot.music().nightcore() ? time - 8 : time);
|
return notes.get(position).time <= time;
|
||||||
} else {
|
} else {
|
||||||
if (finished() && bot.music().loop() != Loop.OFF) {
|
if (finished() && bot.music().loop() != Loop.OFF) {
|
||||||
if (position < notes.size()) {
|
if (position < notes.size()) {
|
||||||
|
|
Loading…
Reference in a new issue