nbs author and original author in the name

This commit is contained in:
Chayapak 2023-08-18 16:59:11 +07:00
parent 27e5909697
commit 7f99a31cbd
2 changed files with 32 additions and 3 deletions

View file

@ -408,7 +408,7 @@ public class MusicCommand extends Command {
if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
// ig very code yup
final String title = currentSong.name;
final String title = currentSong.originalName;
final String songAuthor = currentSong.songAuthor == null || currentSong.songAuthor.equals("") ? "N/A" : currentSong.songAuthor;
final String songOriginalAuthor = currentSong.songOriginalAuthor == null || currentSong.songOriginalAuthor.equals("") ? "N/A" : currentSong.songOriginalAuthor;
final String songDescription = currentSong.songDescription == null || currentSong.songDescription.equals("") ? "N/A" : currentSong.songDescription;

View file

@ -8,6 +8,7 @@ import java.util.Collections;
// Author: hhhzzzsss & _ChipMC_ but i changed most of the stuff
public class Song {
public final ArrayList<Note> notes = new ArrayList<>();
public final String originalName;
public final String name;
public int position = 0; // Current note index
public boolean paused = true;
@ -26,9 +27,32 @@ public class Song {
// public int loopCount = 0; // Number of times to loop
// public int currentLoop = 0; // Number of loops so far
private Bot bot;
private final Bot bot;
public Song (String name, 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, boolean nbs) {
String name = "";
// real ohio code
// TODO: clean this up
if (isNotNullAndNotBlank(songOriginalAuthor) && !isNotNullAndNotBlank(songAuthor)) name = String.format(
"%s - %s",
songOriginalAuthor,
originalName
);
else if (!isNotNullAndNotBlank(songOriginalAuthor) && isNotNullAndNotBlank(songAuthor)) name = String.format(
"%s - %s",
songAuthor,
originalName
);
else if (isNotNullAndNotBlank(songOriginalAuthor) && isNotNullAndNotBlank(songAuthor)) name = String.format(
"%s/%s - %s",
songOriginalAuthor,
songAuthor,
originalName
);
else name = originalName;
this.originalName = originalName;
this.name = name;
this.bot = bot;
this.songName = songName;
@ -38,6 +62,11 @@ public class Song {
this.nbs = nbs;
}
// should this be in idk, util?
private boolean isNotNullAndNotBlank (String text) {
return text != null && !text.isBlank();
}
public Note get (int i) {
return notes.get(i);
}