Temporary fix for the music list (it is even messier now)

This commit is contained in:
Chipmunk 2023-04-16 22:35:17 -04:00
parent 46a3d8e3ef
commit d7a53c9c57

View file

@ -155,26 +155,36 @@ public class MusicCommand {
int i = 0;
for (String filename : filenames) {
final File file = new File(directory, filename);
if (!file.isDirectory()) continue;
final NamedTextColor color = (i++ & 1) == 0 ? NamedTextColor.DARK_GREEN : NamedTextColor.GREEN;
final File file = new File(directory, filename);
final Path relativeFilepath = Path.of(relativePath, filename);
final String escapedPath = escapePath(relativeFilepath.toString());
if (file.isDirectory()) {
directories.add(
Component.text(filename + "/", color)
.clickEvent(ClickEvent.suggestCommand(prefix + "music list " + escapedPath))
.hoverEvent(HoverEvent.showText(Component.translatable("Click to list %s", Component.text(filename, NamedTextColor.GREEN))))
);
} else {
}
for (String filename : filenames) {
final File file = new File(directory, filename);
if (file.isDirectory()) continue;
final NamedTextColor color = (i++ & 1) == 0 ? NamedTextColor.DARK_GREEN : NamedTextColor.GREEN;
final Path relativeFilepath = Path.of(relativePath, filename);
final String escapedPath = escapePath(relativeFilepath.toString());
files.add(
Component.text(filename, color)
.clickEvent(ClickEvent.suggestCommand(prefix + "music play " + escapedPath))
.hoverEvent(HoverEvent.showText(Component.translatable("Click to play %s", Component.text(filename, NamedTextColor.GREEN))))
);
}
}
final ArrayList<Component> mergedList = new ArrayList<>();
for (Component component : directories) mergedList.add(component);