Paper/patches/api/0123-Add-an-asterisk-to-legacy-API-plugins.patch
2021-12-31 19:05:42 -08:00

67 lines
3.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Phoenix616 <max@themoep.de>
Date: Tue, 1 Dec 2020 14:57:02 +0100
Subject: [PATCH] Add an asterisk to legacy API plugins
Not here to name and shame, only so server admins can be aware of which
plugins have and haven't been updated.
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 10028a178b415135d9ea7694e2db8c8c6972c389..2b123aa748d6ba6c1367f376fedb0b9f019ef7fb 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -98,5 +98,11 @@ public interface UnsafeValues {
default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher();
}
+
+ boolean isSupportedApiVersion(String apiVersion);
+
+ static boolean isLegacyPlugin(org.bukkit.plugin.Plugin plugin) {
+ return !Bukkit.getUnsafe().isSupportedApiVersion(plugin.getDescription().getAPIVersion());
+ }
// Paper end
}
diff --git a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
index 4de959bbd1270d7d6ea8e5e69521bcca6abe2138..1aa58c59e1e8738bbdc77752885ff3b18b29de42 100644
--- a/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/PluginsCommand.java
@@ -52,9 +52,15 @@ public class PluginsCommand extends BukkitCommand {
}
Plugin plugin = entry.getValue();
-
+
pluginList.append(plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED);
- pluginList.append(plugin.getDescription().getName());
+ // Paper start - Add an asterisk to legacy plugins (so admins are aware)
+ String pluginName = plugin.getDescription().getName();
+ if (org.bukkit.UnsafeValues.isLegacyPlugin(plugin)) {
+ pluginName += "*";
+ }
+ pluginList.append(pluginName);
+ // Paper end
if (plugin.getDescription().getProvides().size() > 0) {
pluginList.append(" (").append(String.join(", ", plugin.getDescription().getProvides())).append(")");
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index 47b306929654855944b1e95f81c641dea6102096..922bb2cbfaf1e4cd111b7ad286c867c4d9f47e05 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -306,7 +306,14 @@ public final class JavaPluginLoader implements PluginLoader {
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
if (!plugin.isEnabled()) {
- plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());
+ // Paper start - Add an asterisk to legacy plugins (so admins are aware)
+ String enableMsg = "Enabling " + plugin.getDescription().getFullName();
+ if (org.bukkit.UnsafeValues.isLegacyPlugin(plugin)) {
+ enableMsg += "*";
+ }
+
+ plugin.getLogger().info(enableMsg);
+ // Paper end
JavaPlugin jPlugin = (JavaPlugin) plugin;