Changed formatting of songs command

This commit is contained in:
hhhzzzsss 2023-06-11 23:15:58 -05:00
parent f37dd09299
commit 2b14df4289

View file

@ -404,21 +404,37 @@ public class CommandProcessor {
return new String[]{"list"}; return new String[]{"list"};
} }
public String[] getSyntax() { public String[] getSyntax() {
return new String[0]; return new String[] {
"",
"<subdirectory>"};
} }
public String getDescription() { public String getDescription() {
return "Lists available songs"; return "Lists available songs. If an argument is provided, lists all songs in the subdirectory.";
} }
public boolean processCommand(String args) { public boolean processCommand(String args) {
if (args.length() == 0) { if (args.length() == 0) {
String message = "§6" + String.join( List<String> subdirectories = Util.listFilesSilently(SongPlayer.SONG_DIR)
", ", .filter(Files::isDirectory)
Util.listFilesSilently(SongPlayer.SONG_DIR) .map(Path::getFileName)
.map(Path::getFileName) .map(Path::toString)
.map(Path::toString) .map(str -> str + "/")
.collect(Collectors.toList()) .collect(Collectors.toList());
); List<String> songs = Util.listFilesSilently(SongPlayer.SONG_DIR)
SongPlayer.addChatMessage(message); .filter(Files::isRegularFile)
.map(Path::getFileName)
.map(Path::toString)
.collect(Collectors.toList());
if (subdirectories.size() == 0 && songs.size() == 0) {
SongPlayer.addChatMessage("§6No songs found. You can put midi or nbs files in the §3.minecraft/songs §6folder.");
}
else {
if (subdirectories.size() > 0) {
SongPlayer.addChatMessage("§6Subdirectories: §3" + String.join(" ", subdirectories));
}
if (songs.size() > 0) {
SongPlayer.addChatMessage("§6Songs: §7" + String.join(", ", songs));
}
}
return true; return true;
} }
else { else {
@ -435,7 +451,7 @@ public class CommandProcessor {
return new String[] { return new String[] {
"play <playlist>", "play <playlist>",
"create <playlist>", "create <playlist>",
"list [playlist]", "list [<playlist>]",
"delete <playlist> <song>", "delete <playlist> <song>",
"addSong <playlist> <song>", "addSong <playlist> <song>",
"removeSong <playlist> <song>", "removeSong <playlist> <song>",