From d7a53c9c57cfdbe5bfb50cfaa7e2670c80d88884 Mon Sep 17 00:00:00 2001 From: Chipmunk <65827213+ChipmunkMC@users.noreply.github.com> Date: Sun, 16 Apr 2023 22:35:17 -0400 Subject: [PATCH] Temporary fix for the music list (it is even messier now) --- .../chipmunkbot/commands/MusicCommand.java | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java index 5b101e4..c465c65 100644 --- a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java @@ -155,25 +155,35 @@ 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 { - 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)))) - ); - } + 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)))) + ); + } + + 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 mergedList = new ArrayList<>();