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