forked from ChomeNS/chomens-bot-java
port songplayer test song for some reason
This commit is contained in:
parent
8a8d6cc102
commit
97c1d5b963
2 changed files with 50 additions and 4 deletions
|
@ -6,7 +6,9 @@ import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||||
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
|
||||||
import land.chipmunk.chayapak.chomens_bot.plugins.MusicPlayerPlugin;
|
import land.chipmunk.chayapak.chomens_bot.plugins.MusicPlayerPlugin;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.song.Instrument;
|
||||||
import land.chipmunk.chayapak.chomens_bot.song.Loop;
|
import land.chipmunk.chayapak.chomens_bot.song.Loop;
|
||||||
|
import land.chipmunk.chayapak.chomens_bot.song.Note;
|
||||||
import land.chipmunk.chayapak.chomens_bot.song.Song;
|
import land.chipmunk.chayapak.chomens_bot.song.Song;
|
||||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||||
import land.chipmunk.chayapak.chomens_bot.util.TimestampUtilities;
|
import land.chipmunk.chayapak.chomens_bot.util.TimestampUtilities;
|
||||||
|
@ -81,6 +83,7 @@ public class MusicCommand extends Command {
|
||||||
case "noteinstrument" -> noteInstrument(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);
|
||||||
|
case "testsong" -> testSong(context);
|
||||||
default -> Component.text("Invalid action").color(NamedTextColor.RED);
|
default -> Component.text("Invalid action").color(NamedTextColor.RED);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -435,4 +438,47 @@ public class MusicCommand extends Command {
|
||||||
Component.text(songDescription).color(NamedTextColor.AQUA)
|
Component.text(songDescription).color(NamedTextColor.AQUA)
|
||||||
).color(NamedTextColor.GOLD);
|
).color(NamedTextColor.GOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Component testSong (CommandContext context) {
|
||||||
|
final Bot bot = context.bot;
|
||||||
|
|
||||||
|
final Song song = new Song(
|
||||||
|
"test_song",
|
||||||
|
bot,
|
||||||
|
"Test Song",
|
||||||
|
"chayapak",
|
||||||
|
"hhhzzzsss",
|
||||||
|
"SongPlayer's test song ported to ChomeNS Bot",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
int instrumentId = 0;
|
||||||
|
int j = 0;
|
||||||
|
for (int i = 0; i < 400; i++) {
|
||||||
|
j++;
|
||||||
|
|
||||||
|
song.add(
|
||||||
|
new Note(
|
||||||
|
Instrument.fromId(instrumentId),
|
||||||
|
j,
|
||||||
|
1,
|
||||||
|
i * 50,
|
||||||
|
-1,
|
||||||
|
100
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (j > 15) {
|
||||||
|
instrumentId++;
|
||||||
|
if (instrumentId > 15) instrumentId = 0;
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
song.length = 400 * 50;
|
||||||
|
|
||||||
|
bot.music.songQueue.add(song);
|
||||||
|
|
||||||
|
return Component.text("Test song has been added to the song queue").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,20 +37,20 @@ public class Song {
|
||||||
if (isNotNullAndNotBlank(songOriginalAuthor) && !isNotNullAndNotBlank(songAuthor)) name = String.format(
|
if (isNotNullAndNotBlank(songOriginalAuthor) && !isNotNullAndNotBlank(songAuthor)) name = String.format(
|
||||||
"%s - %s",
|
"%s - %s",
|
||||||
songOriginalAuthor,
|
songOriginalAuthor,
|
||||||
originalName
|
isNotNullAndNotBlank(songName) ? songName : originalName
|
||||||
);
|
);
|
||||||
else if (!isNotNullAndNotBlank(songOriginalAuthor) && isNotNullAndNotBlank(songAuthor)) name = String.format(
|
else if (!isNotNullAndNotBlank(songOriginalAuthor) && isNotNullAndNotBlank(songAuthor)) name = String.format(
|
||||||
"%s - %s",
|
"%s - %s",
|
||||||
songAuthor,
|
songAuthor,
|
||||||
originalName
|
isNotNullAndNotBlank(songName) ? songName : originalName
|
||||||
);
|
);
|
||||||
else if (isNotNullAndNotBlank(songOriginalAuthor) && isNotNullAndNotBlank(songAuthor)) name = String.format(
|
else if (isNotNullAndNotBlank(songOriginalAuthor) && isNotNullAndNotBlank(songAuthor)) name = String.format(
|
||||||
"%s/%s - %s",
|
"%s/%s - %s",
|
||||||
songOriginalAuthor,
|
songOriginalAuthor,
|
||||||
songAuthor,
|
songAuthor,
|
||||||
originalName
|
isNotNullAndNotBlank(songName) ? songName : originalName
|
||||||
);
|
);
|
||||||
else name = originalName;
|
else name = isNotNullAndNotBlank(songName) ? songName : originalName;
|
||||||
|
|
||||||
this.originalName = originalName;
|
this.originalName = originalName;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
Loading…
Reference in a new issue