forked from ChomeNS/chomens-bot-java
Add tracks to *music info
This commit is contained in:
parent
76b4885c1c
commit
eaa42d40a3
6 changed files with 31 additions and 8 deletions
|
@ -603,6 +603,7 @@ public class MusicCommand extends Command {
|
|||
if (currentSong.requester != null) components.add(Component.translatable("Requester: %s", Component.text(currentSong.requester).color(valueColor)).color(keyColor));
|
||||
if (currentSong.songAuthor != null && !currentSong.songAuthor.isBlank()) components.add(Component.translatable("Author: %s", Component.text(currentSong.songAuthor).color(valueColor)).color(keyColor));
|
||||
if (currentSong.songOriginalAuthor != null && !currentSong.songOriginalAuthor.isBlank()) components.add(Component.translatable("Original author: %s", Component.text(currentSong.songOriginalAuthor).color(valueColor)).color(keyColor));
|
||||
if (currentSong.tracks != null && !currentSong.tracks.isBlank()) components.add(Component.translatable("Tracks: %s", Component.text(currentSong.tracks).color(valueColor)).color(keyColor));
|
||||
if (currentSong.songDescription != null && !currentSong.songDescription.isBlank()) components.add(Component.translatable("Description: %s", Component.text(currentSong.songDescription).color(valueColor)).color(keyColor));
|
||||
|
||||
return Component.join(JoinConfiguration.newlines(), components);
|
||||
|
@ -620,6 +621,7 @@ public class MusicCommand extends Command {
|
|||
"chayapak",
|
||||
"hhhzzzsss",
|
||||
"SongPlayer's test song ported to ChomeNS Bot",
|
||||
null,
|
||||
false
|
||||
);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ public class MidiConverter implements Converter {
|
|||
|
||||
String songName = null;
|
||||
|
||||
final StringBuilder tracks = new StringBuilder();
|
||||
final StringBuilder text = new StringBuilder();
|
||||
|
||||
boolean isFirst = true;
|
||||
|
@ -49,10 +50,15 @@ public class MidiConverter implements Converter {
|
|||
if (message instanceof MetaMessage mm) {
|
||||
if (mm.getType() == SET_TEMPO) {
|
||||
tempoEvents.add(event);
|
||||
} else if (mm.getType() == TRACK_NAME && isFirst) {
|
||||
} else if (mm.getType() == TRACK_NAME) {
|
||||
final String stringTitle = new String(mm.getData(), StandardCharsets.UTF_8);
|
||||
|
||||
if (!stringTitle.isBlank()) {
|
||||
if (stringTitle.isBlank()) continue;
|
||||
|
||||
tracks.append(stringTitle);
|
||||
tracks.append("\n");
|
||||
|
||||
if (isFirst) {
|
||||
songName = stringTitle + " (" + name + ")"; // i have put the ` (filename)` just in case the sequence is getting sus (like Track 2 for example)
|
||||
|
||||
isFirst = false;
|
||||
|
@ -69,10 +75,13 @@ public class MidiConverter implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
String stringTracks = tracks.toString();
|
||||
String stringText = text.toString();
|
||||
if (stringText.endsWith("\n")) stringText = stringText.substring(0, stringText.length() - 1);
|
||||
|
||||
final Song song = new Song(name, bot, songName, null, null, stringText, false);
|
||||
if (stringText.endsWith("\n")) stringText = stringText.substring(0, stringText.length() - 1);
|
||||
if (stringTracks.endsWith("\n")) stringTracks = stringTracks.substring(0, stringTracks.length() - 1);
|
||||
|
||||
final Song song = new Song(name, bot, songName, null, null, stringText, stringTracks, false);
|
||||
|
||||
tempoEvents.sort(Comparator.comparingLong(MidiEvent::getTick));
|
||||
|
||||
|
|
|
@ -165,7 +165,16 @@ public class NBSConverter implements Converter {
|
|||
}
|
||||
}
|
||||
|
||||
Song song = new Song(!songName.isBlank() ? songName : fileName, bot, songName, songAuthor, songOriginalAuthor, songDescription, true);
|
||||
final StringBuilder layerNames = new StringBuilder();
|
||||
|
||||
for (NBSLayer layer : nbsLayers) {
|
||||
layerNames.append(layer.name);
|
||||
layerNames.append("\n");
|
||||
}
|
||||
|
||||
final String stringLayerNames = layerNames.toString();
|
||||
|
||||
Song song = new Song(!songName.isBlank() ? songName : fileName, bot, songName, songAuthor, songOriginalAuthor, songDescription, stringLayerNames.substring(0, stringLayerNames.length() - 1), true);
|
||||
if (loop > 0) {
|
||||
song.loopPosition = getMilliTime(loopStartTick, tempo);
|
||||
// song.loopCount = maxLoopCount;
|
||||
|
|
|
@ -24,6 +24,8 @@ public class Song {
|
|||
public String songOriginalAuthor;
|
||||
public String songDescription;
|
||||
|
||||
public String tracks;
|
||||
|
||||
public final boolean nbs;
|
||||
|
||||
// public int loopCount = 0; // Number of times to loop
|
||||
|
@ -31,13 +33,14 @@ public class Song {
|
|||
|
||||
private final Bot bot;
|
||||
|
||||
public Song (String originalName, Bot bot, String songName, String songAuthor, String songOriginalAuthor, String songDescription, boolean nbs) {
|
||||
public Song (String originalName, Bot bot, String songName, String songAuthor, String songOriginalAuthor, String songDescription, String tracks, boolean nbs) {
|
||||
this.originalName = originalName;
|
||||
this.bot = bot;
|
||||
this.songName = songName;
|
||||
this.songAuthor = songAuthor;
|
||||
this.songOriginalAuthor = songOriginalAuthor;
|
||||
this.songDescription = songDescription;
|
||||
this.tracks = tracks;
|
||||
this.nbs = nbs;
|
||||
|
||||
updateName();
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SongPlayerConverter implements Converter {
|
|||
int loopCount = buffer.get() & 0xFF;
|
||||
long loopPosition = buffer.getLong();
|
||||
|
||||
Song song = new Song(fileName, bot, !songName.trim().isEmpty() ? songName : null, null, null, null, false);
|
||||
Song song = new Song(fileName, bot, !songName.trim().isEmpty() ? songName : null, null, null, null, null, false);
|
||||
song.length = songLength;
|
||||
// song.looping = loop > 0;
|
||||
// song.loopCount = loopCount;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class TextFileConverter implements Converter {
|
|||
|
||||
int length = 0;
|
||||
|
||||
final Song song = new Song(fileName, bot, null, null, null, null, false);
|
||||
final Song song = new Song(fileName, bot, null, null, null, null, null, false);
|
||||
|
||||
for (String line : data.split("\r\n|\r|\n")) {
|
||||
if (line.isBlank()) continue;
|
||||
|
|
Loading…
Reference in a new issue