mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly Paper Changes: 0514fc4e2 Add missing effects 8f5d9effd Add getMainThreadExecutor to BukkitScheduler 313b5020b Allow adding items to BlockDropItemEvent (#5093) 9a556d9da [CI-SKIP] [Auto] Rebuild Patches 72b2768ad Inline shift fields in EnumDirection (#5082) ffff53fa7 added option to disable pathfinding updates on block changes (#5123) b67081fd7 add DragonEggFormEvent (fixes #5110) (#5112) 3eefafbaf Fix javadoc build 0081ed1c4 Add javadoc step to GH Actions 01082503e Add dropLeash variable to EntityUnleashEvent (#5130) 31f9f869a [CI-SKIP] Fix YourKit links in readme, fixes #5091 8ac27aa38 [Auto] Updated Upstream (CraftBukkit) c4d9cc831 [Auto] Updated Upstream (Bukkit/CraftBukkit) d0477d326 [Auto] Updated Upstream (CraftBukkit) d9f5f7018 EntityMoveEvent (#4614)
This commit is contained in:
114
patches/api/0026-Spigot-Improve-output-of-plugins-command.patch
Normal file
114
patches/api/0026-Spigot-Improve-output-of-plugins-command.patch
Normal file
@@ -0,0 +1,114 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user