From 0d73ddd791f7971d5cf4547e772ed9d40b6c6811 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:33:29 +0700 Subject: [PATCH] Fix newline on SeenCommand --- .../me/chayapak1/chomens_bot/commands/SeenCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java index e0016f3..257733e 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java @@ -10,12 +10,16 @@ import me.chayapak1.chomens_bot.command.TrustLevel; import me.chayapak1.chomens_bot.plugins.PlayersPersistentDataPlugin; import me.chayapak1.chomens_bot.util.ColorUtilities; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.format.NamedTextColor; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; + public class SeenCommand extends Command { public SeenCommand () { super( @@ -36,13 +40,13 @@ public class SeenCommand extends Command { boolean online = false; - Component onlineComponents = Component.empty(); + final List onlineComponents = new ArrayList<>(); for (Bot eachBot : bot.bots) { if (eachBot.players.getEntry(player) != null) { online = true; - onlineComponents = onlineComponents.append( + onlineComponents.add( Component.empty() .append(Component.text(player)) .append(Component.text(" is currently online on ")) @@ -52,7 +56,7 @@ public class SeenCommand extends Command { } } - if (online) return onlineComponents; + if (online) return Component.join(JoinConfiguration.newlines(), onlineComponents); final JsonElement playerElement = PlayersPersistentDataPlugin.playersObject.get(player); if (playerElement == null) throw new CommandException(Component.translatable(