From 32c3801acf8fdf0dd2c88b051960b107d04e2b35 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 26 Oct 2024 18:33:41 +0700 Subject: [PATCH] Fix SeenCommand when the same player is online in multiple servers --- .../chomens_bot/commands/SeenCommand.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 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 509f16d..e0016f3 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/SeenCommand.java @@ -34,14 +34,26 @@ public class SeenCommand extends Command { final String player = context.getString(true, true); + boolean online = false; + + Component onlineComponents = Component.empty(); + for (Bot eachBot : bot.bots) { - if (eachBot.players.getEntry(player) != null) return Component.empty() - .append(Component.text(player)) - .append(Component.text(" is currently online on ")) - .append(Component.text(eachBot.host + ":" + eachBot.port)) - .color(NamedTextColor.RED); + if (eachBot.players.getEntry(player) != null) { + online = true; + + onlineComponents = onlineComponents.append( + Component.empty() + .append(Component.text(player)) + .append(Component.text(" is currently online on ")) + .append(Component.text(eachBot.host + ":" + eachBot.port)) + .color(NamedTextColor.RED) + ); + } } + if (online) return onlineComponents; + final JsonElement playerElement = PlayersPersistentDataPlugin.playersObject.get(player); if (playerElement == null) throw new CommandException(Component.translatable( "%s was never seen",