From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Thu, 15 Jul 2021 23:43:04 -0500
Subject: [PATCH] Clean up version command output for console


diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
index 57a21495843f3a144cd73473cdc8781d6129b7ca..7d9ffef457da0571bb2254c35b908d9c22a3dd46 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -168,14 +168,14 @@ public class VersionCommand extends BukkitCommand {
                 lastCheck = System.currentTimeMillis();
                 hasVersion = false;
             } else {
-                sender.sendMessage(versionMessage);
+                sendVersionMessage(sender); // Purpur
                 return;
             }
         }
         versionLock.lock();
         try {
             if (hasVersion) {
-                sender.sendMessage(versionMessage);
+                sendVersionMessage(sender); // Purpur
                 return;
             }
             versionWaiters.add(sender);
@@ -256,7 +256,7 @@ public class VersionCommand extends BukkitCommand {
             hasVersion = true;
             versionTaskStarted = false;
             for (CommandSender sender : versionWaiters) {
-                sender.sendMessage(versionMessage);
+                sendVersionMessage(sender); // Purpur
             }
             versionWaiters.clear();
         } finally {
@@ -284,4 +284,27 @@ public class VersionCommand extends BukkitCommand {
             return -1;
         }
     }
+
+    // Purpur start
+    private void sendVersionMessage(CommandSender sender) {
+        if (!(sender instanceof org.bukkit.command.ConsoleCommandSender)) {
+            sender.sendMessage(versionMessage);
+            return;
+        }
+        List<Component> list = new ArrayList<>();
+        if (versionMessage.children().size() == 1) {
+            versionMessage.children().get(0).children().forEach(child -> {
+                if (child.children().size() > 1) {
+                    list.addAll(child.children());
+                } else {
+                    list.add(child);
+                }
+            });
+        } else {
+            list.addAll(versionMessage.children());
+        }
+        list.removeIf(component -> net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText().serialize(component).equals("\n"));
+        list.forEach(sender::sendMessage);
+    }
+    // Purpur end
 }
