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 <mc.cache@web.de>
Dieser Commit ist enthalten in:
Owen1212055 2021-11-20 11:28:18 -05:00 committet von GitHub
Ursprung 1e5e9e04b4
Commit fc4517fe4c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -47,6 +47,9 @@ import org.bukkit.plugin.PluginManager;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -148,9 +151,13 @@ public class FaweBukkit implements IFawe, Listener {
@Override @Override
public String getDebugInfo() { public String getDebugInfo() {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
List<Plugin> 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("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) { for (Plugin p : plugins) {
msg.append(" - ").append(p.getName()).append(":").append("\n") msg.append(" - ").append(p.getName()).append(":").append("\n")
.append(" • Version: ").append(p.getDescription().getVersion()).append("\n") .append(" • Version: ").append(p.getDescription().getVersion()).append("\n")