diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java index 7973e8b..bcaacaa 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/MusicCommand.java @@ -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 ); diff --git a/src/main/java/me/chayapak1/chomens_bot/song/MidiConverter.java b/src/main/java/me/chayapak1/chomens_bot/song/MidiConverter.java index c0ac989..6d66547 100644 --- a/src/main/java/me/chayapak1/chomens_bot/song/MidiConverter.java +++ b/src/main/java/me/chayapak1/chomens_bot/song/MidiConverter.java @@ -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)); diff --git a/src/main/java/me/chayapak1/chomens_bot/song/NBSConverter.java b/src/main/java/me/chayapak1/chomens_bot/song/NBSConverter.java index be46bc4..262c196 100644 --- a/src/main/java/me/chayapak1/chomens_bot/song/NBSConverter.java +++ b/src/main/java/me/chayapak1/chomens_bot/song/NBSConverter.java @@ -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; diff --git a/src/main/java/me/chayapak1/chomens_bot/song/Song.java b/src/main/java/me/chayapak1/chomens_bot/song/Song.java index 0c5c449..47ee7e5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/song/Song.java +++ b/src/main/java/me/chayapak1/chomens_bot/song/Song.java @@ -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(); diff --git a/src/main/java/me/chayapak1/chomens_bot/song/SongPlayerConverter.java b/src/main/java/me/chayapak1/chomens_bot/song/SongPlayerConverter.java index a94b17d..5cb46b4 100644 --- a/src/main/java/me/chayapak1/chomens_bot/song/SongPlayerConverter.java +++ b/src/main/java/me/chayapak1/chomens_bot/song/SongPlayerConverter.java @@ -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; diff --git a/src/main/java/me/chayapak1/chomens_bot/song/TextFileConverter.java b/src/main/java/me/chayapak1/chomens_bot/song/TextFileConverter.java index e3be434..a20e887 100644 --- a/src/main/java/me/chayapak1/chomens_bot/song/TextFileConverter.java +++ b/src/main/java/me/chayapak1/chomens_bot/song/TextFileConverter.java @@ -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;