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

This commit is contained in:
BillyGalbreath 2020-07-04 20:04:35 -05:00
parent 7de9b9d112
commit 3cf7163de4

View file

@ -26,12 +26,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- 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 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
// 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);
}