Fix /plugins list not alphabetical to players (#3790)
This commit is contained in:
parent
7e03e44ea3
commit
4faf9703be
1 changed files with 26 additions and 5 deletions
|
@ -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
|
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
|
--- a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
|
||||||
+++ b/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;
|
@@ -3,6 +3,9 @@ package org.bukkit.command.defaults;
|
||||||
|
@ -18,7 +18,7 @@ index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff9
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -49,24 +52,33 @@ public class PluginsCommand extends BukkitCommand {
|
@@ -49,34 +52,51 @@ public class PluginsCommand extends BukkitCommand {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String getPluginList() {
|
private String getPluginList() {
|
||||||
|
@ -26,12 +26,12 @@ index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff9
|
||||||
- Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
- Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ TreeMap<String, Plugin> plugins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
+ TreeMap<String, Plugin> plugins = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
+
|
||||||
- for (Plugin plugin : plugins) {
|
|
||||||
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
+ plugins.put(plugin.getDescription().getName(), plugin);
|
+ plugins.put(plugin.getDescription().getName(), plugin);
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
|
- for (Plugin plugin : plugins) {
|
||||||
+ StringBuilder pluginList = new StringBuilder();
|
+ StringBuilder pluginList = new StringBuilder();
|
||||||
+ for (Map.Entry<String, Plugin> entry : plugins.entrySet()) {
|
+ for (Map.Entry<String, Plugin> entry : plugins.entrySet()) {
|
||||||
if (pluginList.length() > 0) {
|
if (pluginList.length() > 0) {
|
||||||
|
@ -58,3 +58,24 @@ index e8a7f435fb30da3506b2b4fa8c5675c829edc105..4a75997f93f5c33f19200994562aaff9
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spigot start
|
// 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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue