mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
all the patches are done
This commit is contained in:
115
patches/api/0022-Spigot-Improve-output-of-plugins-command.patch
Normal file
115
patches/api/0022-Spigot-Improve-output-of-plugins-command.patch
Normal file
@@ -0,0 +1,115 @@
|
||||
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
|
||||
|
||||
Co-authored-by: Oharass <oharass@bk.ru>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
|
||||
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,14 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+// Spigot start
|
||||
+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 +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.sendMessage(getPluginListSpigot());
|
||||
+ } else {
|
||||
+ sender.sendMessage("Plugins " + getPluginList());
|
||||
+ }
|
||||
+ // Spigot end
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,4 +85,73 @@ public class PluginsCommand extends BukkitCommand {
|
||||
// Paper end
|
||||
}
|
||||
|
||||
+ // Spigot start
|
||||
+ @NotNull
|
||||
+ private TextComponent getPluginListSpigot() {
|
||||
+ Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
|
||||
+ TextComponent.Builder builder = Component.text();
|
||||
+ builder.append(Component.text("Plugins (" + plugins.length + "): "));
|
||||
+
|
||||
+ int index = 0;
|
||||
+ for (Plugin plugin : plugins) {
|
||||
+ if (index++ > 0) {
|
||||
+ builder.append(Component.text(", ", NamedTextColor.WHITE));
|
||||
+ }
|
||||
+
|
||||
+ // Event components
|
||||
+ PluginDescriptionFile description = plugin.getDescription();
|
||||
+ TextComponent.Builder hover = Component.text();
|
||||
+ hover.append(Component.text("Version: ", NamedTextColor.WHITE)).append(Component.text(description.getVersion(), NamedTextColor.GREEN));
|
||||
+
|
||||
+ if (description.getDescription() != null) {
|
||||
+ hover.append(Component.newline())
|
||||
+ .append(Component.text("Description: ", NamedTextColor.WHITE))
|
||||
+ .append(Component.text(description.getDescription(), NamedTextColor.GREEN));
|
||||
+ }
|
||||
+
|
||||
+ if (description.getWebsite() != null) {
|
||||
+ 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) {
|
||||
+ hover.append(Component.text("Author: "));
|
||||
+ } else {
|
||||
+ hover.append(Component.text("Authors: "));
|
||||
+ }
|
||||
+
|
||||
+ hover.append(getAuthors(description));
|
||||
+ }
|
||||
+
|
||||
+ // Plugin list entry
|
||||
+ 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) {
|
||||
+ builder.append(Component.text(" (", NamedTextColor.WHITE)).append(Component.text(String.join(", ", plugin.getDescription().getProvides()))).append(Component.text(")"));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ private TextComponent getAuthors(@NotNull final PluginDescriptionFile description) {
|
||||
+ TextComponent.Builder builder = Component.text();
|
||||
+ List<String> authors = description.getAuthors();
|
||||
+
|
||||
+ for (int i = 0; i < authors.size(); i++) {
|
||||
+ if (i > 0) {
|
||||
+ builder.append(Component.text(i < authors.size() - 1 ? ", " : " and ", NamedTextColor.WHITE));
|
||||
+ }
|
||||
+
|
||||
+ builder.append(Component.text(authors.get(i), NamedTextColor.GREEN));
|
||||
+ }
|
||||
+
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
Reference in New Issue
Block a user