mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 12dec20 Bump paerweight to 1.1.7 e33ed89 Get short commit ref using a more proper method 7d6147d Remove now unneeded patch due to paperweight 1.1.7 e72fa41 Update task dependency for includeMappings so the new task isn't skipped 0ad5526 Trim whitspace off of git hash (oops) Tuinity Changes: e878ba9 Update paper 2bd2849 Bring back fix codec spam patch
115 lines
5.1 KiB
Diff
115 lines
5.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Parker Hawke <hawkeboyz2@hotmail.com>
|
|
Date: Sat, 27 Jun 2020 18:43:37 -0400
|
|
Subject: [PATCH] Spigot - Improve output of plugins command
|
|
|
|
|
|
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
|
|
--- 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;
|
|
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 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 {
|
|
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());
|
|
+ } else {
|
|
+ sender.sendMessage("Plugins " + getPluginList());
|
|
+ }
|
|
+ // Spigot end
|
|
return true;
|
|
}
|
|
|
|
@@ -71,4 +86,72 @@ public class PluginsCommand extends BukkitCommand {
|
|
// Paper end
|
|
}
|
|
|
|
+ // Spigot start
|
|
+ @NotNull
|
|
+ private BaseComponent[] getPluginListSpigot() {
|
|
+ Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
|
+ ComponentBuilder pluginList = new ComponentBuilder("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);
|
|
+ }
|
|
+
|
|
+ // 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);
|
|
+
|
|
+ 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);
|
|
+ }
|
|
+
|
|
+ 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);
|
|
+ }
|
|
+
|
|
+ if (!description.getAuthors().isEmpty()) {
|
|
+ if (description.getAuthors().size() == 1) {
|
|
+ hoverEventComponents.append("\nAuthor: ");
|
|
+ } else {
|
|
+ hoverEventComponents.append("\nAuthors: ");
|
|
+ }
|
|
+
|
|
+ hoverEventComponents.color(net.md_5.bungee.api.ChatColor.WHITE).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);
|
|
+
|
|
+ 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(")");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return pluginList.create();
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ private BaseComponent[] getAuthors(@NotNull final PluginDescriptionFile description) {
|
|
+ ComponentBuilder result = new ComponentBuilder();
|
|
+ List<String> 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);
|
|
+ }
|
|
+
|
|
+ result.append(authors.get(i)).color(net.md_5.bungee.api.ChatColor.GREEN);
|
|
+ }
|
|
+
|
|
+ return result.create();
|
|
+ }
|
|
+ // Spigot end
|
|
}
|