From fc4517fe4ca463183720924e024a1928df803e05 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Sat, 20 Nov 2021 11:28:18 -0500 Subject: [PATCH] feat: Sort plugins on debugpaste (#1429) * Replace plugins with an array and sort them by their name. Resolves #1428 * Use comparator Co-authored-by: Alex --- .../com/fastasyncworldedit/bukkit/FaweBukkit.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java index b24c1065d..5e5671dcf 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/FaweBukkit.java @@ -47,6 +47,9 @@ import org.bukkit.plugin.PluginManager; import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; import java.util.UUID; import java.util.function.Supplier; @@ -148,9 +151,13 @@ public class FaweBukkit implements IFawe, Listener { @Override public String getDebugInfo() { StringBuilder msg = new StringBuilder(); - Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); + + List plugins = new ArrayList<>(); + Collections.addAll(plugins, Bukkit.getServer().getPluginManager().getPlugins()); + plugins.sort(Comparator.comparing(Plugin::getName)); + msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n"); - msg.append("Plugins (").append(plugins.length).append("):\n"); + msg.append("Plugins (").append(plugins.size()).append("):\n"); for (Plugin p : plugins) { msg.append(" - ").append(p.getName()).append(":").append("\n") .append(" • Version: ").append(p.getDescription().getVersion()).append("\n")