Fix /plugins list not alphabetical to players (#3790)

This commit is contained in:
BillyGalbreath 2020-07-04 20:04:35 -05:00 committed by GitHub
parent 7e03e44ea3
commit 4faf9703be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Make /plugins list alphabetical
diff --git a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff99bdd422f 100644
index e8a7f435fb30da3506b2b4fa8c5675c829edc105..ba399ee5ab33b4fd8741bce53509a17b1aabc84d 100644
--- a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
@@ -3,6 +3,9 @@ package org.bukkit.command.defaults;
@ -18,7 +18,7 @@ index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff9
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@@ -49,24 +52,33 @@ public class PluginsCommand extends BukkitCommand {
@@ -49,34 +52,51 @@ public class PluginsCommand extends BukkitCommand {
@NotNull
private String getPluginList() {
@ -26,12 +26,12 @@ index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff9
- Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
+ // Paper start
+ TreeMap<String, Plugin> plugins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- for (Plugin plugin : plugins) {
+
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
+ plugins.put(plugin.getDescription().getName(), plugin);
+ }
+
- for (Plugin plugin : plugins) {
+ StringBuilder pluginList = new StringBuilder();
+ for (Map.Entry<String, Plugin> entry : plugins.entrySet()) {
if (pluginList.length() > 0) {
@ -58,3 +58,24 @@ index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff9
}
// Spigot start
@NotNull
private BaseComponent[] getPluginListSpigot() {
- Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
- ComponentBuilder pluginList = new ComponentBuilder("Plugins (" + plugins.length + "): ");
+ // Paper start
+ TreeMap<String, Plugin> plugins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
+ plugins.put(plugin.getDescription().getName(), plugin);
+ }
+ ComponentBuilder pluginList = new ComponentBuilder("Plugins (" + plugins.size() + "): ");
+ // Paper end
int index = 0;
- for (Plugin plugin : plugins) {
+ // Paper start
+ for (Map.Entry<String, Plugin> entry : plugins.entrySet()) {
+ Plugin plugin = entry.getValue();
+ // Paper end
if (index++ > 0) {
pluginList.append(", ", FormatRetention.NONE).color(net.md_5.bungee.api.ChatColor.WHITE);
}