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>
This commit is contained in:
Owen1212055 2021-11-20 11:28:18 -05:00 committed by GitHub
parent 1e5e9e04b4
commit fc4517fe4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -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<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("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")