From aeba24c6dd57f0c69fc0a087b144675ebed3e3ef Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Mon, 10 Apr 2023 13:31:44 +0700 Subject: [PATCH] actually split the among us --- .../chomens_bot/commands/MusicCommand.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java index b01fecc..35d7eb1 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java @@ -208,7 +208,7 @@ public class MusicCommand implements Command { return result; }); - final List list = new ArrayList<>(); + final List fullList = new ArrayList<>(); int i = 0; for (String filename : filenames) { final String pathString = path.toString(); @@ -221,13 +221,13 @@ public class MusicCommand implements Command { location = Paths.get(""); // wtf mabe } final String joinedPath = (args.length < 2) ? filename : Paths.get(location.getFileName().toString(), filename).toString(); - list.add( + fullList.add( Component .text(filename, (i++ & 1) == 0 ? NamedTextColor.YELLOW : NamedTextColor.GOLD) .clickEvent( ClickEvent.suggestCommand( prefix + - "music" + // ? How do I make this dynamic? + name() + (file.isFile() ? " play " : " list ") + joinedPath.replace("'", "\\'") ) @@ -235,8 +235,19 @@ public class MusicCommand implements Command { ); } - final Component component = Component.join(JoinConfiguration.separator(Component.space()), list); - context.sendOutput(component); + final int eachSize = 100; + + int index = 0; + + while (index < fullList.size()) { + List list = fullList.subList(index, Math.min(index + eachSize, fullList.size())); + + final Component component = Component.join(JoinConfiguration.separator(Component.space()), list); + context.sendOutput(component); + + index += eachSize; + list.clear(); + } return Component.text("success"); }