diff --git a/patches/api/0022-Spigot-Improve-output-of-plugins-command.patch b/patches/api/0022-Spigot-Improve-output-of-plugins-command.patch index bb3715283..a44be9cf1 100644 --- a/patches/api/0022-Spigot-Improve-output-of-plugins-command.patch +++ b/patches/api/0022-Spigot-Improve-output-of-plugins-command.patch @@ -3,35 +3,35 @@ From: Parker Hawke Date: Sat, 27 Jun 2020 18:43:37 -0400 Subject: [PATCH] Spigot - Improve output of plugins command +Co-authored-by: Oharass diff --git a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java -index 1aa58c59e1e8738bbdc77752885ff3b18b29de42..4974fc518c3645e6e060ff52e71a47a86d52ec5c 100644 +index 1aa58c59e1e8738bbdc77752885ff3b18b29de42..46525191653e4ac0e0366c0357f368c0b709f20d 100644 --- a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java +++ b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java -@@ -11,6 +11,15 @@ import org.bukkit.ChatColor; +@@ -11,6 +11,14 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; +// Spigot start -+import net.md_5.bungee.api.chat.BaseComponent; -+import net.md_5.bungee.api.chat.ClickEvent; -+import net.md_5.bungee.api.chat.ComponentBuilder; -+import net.md_5.bungee.api.chat.HoverEvent; -+import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.TextComponent; ++import net.kyori.adventure.text.format.NamedTextColor; ++import net.kyori.adventure.text.event.ClickEvent; +import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginDescriptionFile; +// Spigot end public class PluginsCommand extends BukkitCommand { public PluginsCommand(@NotNull String name) { -@@ -25,7 +34,13 @@ public class PluginsCommand extends BukkitCommand { +@@ -25,7 +33,13 @@ public class PluginsCommand extends BukkitCommand { public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { if (!testPermission(sender)) return true; - sender.sendMessage("Plugins " + getPluginList()); + // Spigot start + if (sender instanceof Player && sender.hasPermission("bukkit.command.version")) { -+ sender.spigot().sendMessage(getPluginListSpigot()); ++ sender.sendMessage(getPluginListSpigot()); + } else { + sender.sendMessage("Plugins " + getPluginList()); + } @@ -39,76 +39,77 @@ index 1aa58c59e1e8738bbdc77752885ff3b18b29de42..4974fc518c3645e6e060ff52e71a47a8 return true; } -@@ -71,4 +86,72 @@ public class PluginsCommand extends BukkitCommand { +@@ -71,4 +85,73 @@ public class PluginsCommand extends BukkitCommand { // Paper end } + // Spigot start + @NotNull -+ private BaseComponent[] getPluginListSpigot() { ++ private TextComponent getPluginListSpigot() { + Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); -+ ComponentBuilder pluginList = new ComponentBuilder("Plugins (" + plugins.length + "): "); ++ TextComponent.Builder builder = Component.text(); ++ builder.append(Component.text("Plugins (" + plugins.length + "): ")); + + int index = 0; + for (Plugin plugin : plugins) { + if (index++ > 0) { -+ pluginList.append(", ", FormatRetention.NONE).color(net.md_5.bungee.api.ChatColor.WHITE); ++ builder.append(Component.text(", ", NamedTextColor.WHITE)); + } + + // Event components + PluginDescriptionFile description = plugin.getDescription(); -+ ComponentBuilder hoverEventComponents = new ComponentBuilder(); -+ hoverEventComponents.append("Version: ").color(net.md_5.bungee.api.ChatColor.WHITE).append(description.getVersion()).color(net.md_5.bungee.api.ChatColor.GREEN); ++ TextComponent.Builder hover = Component.text(); ++ hover.append(Component.text("Version: ", NamedTextColor.WHITE)).append(Component.text(description.getVersion(), NamedTextColor.GREEN)); + + if (description.getDescription() != null) { -+ hoverEventComponents.append("\nDescription: ").color(net.md_5.bungee.api.ChatColor.WHITE).append(description.getDescription()).color(net.md_5.bungee.api.ChatColor.GREEN); ++ hover.append(Component.newline()) ++ .append(Component.text("Description: ", NamedTextColor.WHITE)) ++ .append(Component.text(description.getDescription(), NamedTextColor.GREEN)); + } + + if (description.getWebsite() != null) { -+ hoverEventComponents.append("\nWebsite: ").color(net.md_5.bungee.api.ChatColor.WHITE).append(description.getWebsite()).color(net.md_5.bungee.api.ChatColor.GREEN); ++ hover.append(Component.newline()) ++ .append(Component.text("Website: ", NamedTextColor.WHITE)) ++ .append(Component.text(description.getWebsite(), NamedTextColor.GREEN)); + } + + if (!description.getAuthors().isEmpty()) { ++ hover.append(Component.newline()); + if (description.getAuthors().size() == 1) { -+ hoverEventComponents.append("\nAuthor: "); ++ hover.append(Component.text("Author: ")); + } else { -+ hoverEventComponents.append("\nAuthors: "); ++ hover.append(Component.text("Authors: ")); + } + -+ hoverEventComponents.color(net.md_5.bungee.api.ChatColor.WHITE).append(getAuthors(description)); ++ hover.append(getAuthors(description)); + } + -+ HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverEventComponents.create()); -+ ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/version " + description.getName()); -+ + // Plugin list entry -+ pluginList.append(plugin.getDescription().getName()); -+ pluginList.color(plugin.isEnabled() ? net.md_5.bungee.api.ChatColor.GREEN : net.md_5.bungee.api.ChatColor.RED); -+ pluginList.event(hoverEvent).event(clickEvent); ++ builder.append(Component.text(plugin.getDescription().getName(), plugin.isEnabled() ? NamedTextColor.GREEN : NamedTextColor.RED) ++ .hoverEvent(hover.build()).clickEvent(ClickEvent.suggestCommand("/version " + description.getName()))); + + if (plugin.getDescription().getProvides().size() > 0) { -+ pluginList.append("( ", FormatRetention.NONE).color(net.md_5.bungee.api.ChatColor.WHITE).append(String.join(", ", plugin.getDescription().getProvides())).append(")"); ++ builder.append(Component.text(" (", NamedTextColor.WHITE)).append(Component.text(String.join(", ", plugin.getDescription().getProvides()))).append(Component.text(")")); + } + } + -+ return pluginList.create(); ++ return builder.build(); + } + + @NotNull -+ private BaseComponent[] getAuthors(@NotNull final PluginDescriptionFile description) { -+ ComponentBuilder result = new ComponentBuilder(); ++ private TextComponent getAuthors(@NotNull final PluginDescriptionFile description) { ++ TextComponent.Builder builder = Component.text(); + List authors = description.getAuthors(); + + for (int i = 0; i < authors.size(); i++) { + if (i > 0) { -+ result.append(i < authors.size() - 1 ? ", " : " and ", FormatRetention.NONE); -+ result.color(net.md_5.bungee.api.ChatColor.WHITE); ++ builder.append(Component.text(i < authors.size() - 1 ? ", " : " and ", NamedTextColor.WHITE)); + } + -+ result.append(authors.get(i)).color(net.md_5.bungee.api.ChatColor.GREEN); ++ builder.append(Component.text(authors.get(i), NamedTextColor.GREEN)); + } + -+ return result.create(); ++ return builder.build(); + } + // Spigot end } diff --git a/patches/api/0025-Alphabetize-in-game-plugins-list.patch b/patches/api/0025-Alphabetize-in-game-plugins-list.patch index d10192b17..c9ba2a0dc 100644 --- a/patches/api/0025-Alphabetize-in-game-plugins-list.patch +++ b/patches/api/0025-Alphabetize-in-game-plugins-list.patch @@ -5,23 +5,15 @@ Subject: [PATCH] Alphabetize in-game /plugins list diff --git a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java -index 4974fc518c3645e6e060ff52e71a47a86d52ec5c..37cc5d7e9db89e4ef7ab16da1b159bd19134a4ff 100644 +index 46525191653e4ac0e0366c0357f368c0b709f20d..0b4937dc6d003caf0f43a01a5a0801d5804082bf 100644 --- a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java +++ b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java -@@ -2,6 +2,7 @@ package org.bukkit.command.defaults; - - import java.util.Arrays; - import java.util.Collections; -+import java.util.Comparator; - import java.util.List; - import java.util.Map; - import java.util.TreeMap; -@@ -89,7 +90,7 @@ public class PluginsCommand extends BukkitCommand { +@@ -88,7 +88,7 @@ public class PluginsCommand extends BukkitCommand { // Spigot start @NotNull - private BaseComponent[] getPluginListSpigot() { + private TextComponent getPluginListSpigot() { - Plugin[] plugins = Bukkit.getPluginManager().getPlugins(); -+ Plugin[] plugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).sorted(Comparator.comparing(plugin -> plugin.getName().toLowerCase())).toArray(Plugin[]::new); // Purpur - ComponentBuilder pluginList = new ComponentBuilder("Plugins (" + plugins.length + "): "); ++ Plugin[] plugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).sorted(java.util.Comparator.comparing(plugin -> plugin.getName().toLowerCase())).toArray(Plugin[]::new); // Purpur + TextComponent.Builder builder = Component.text(); + builder.append(Component.text("Plugins (" + plugins.length + "): ")); - int index = 0;