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<>();