From 90a88fcc044e930f6e7343bda56bbb4500c59fb7 Mon Sep 17 00:00:00 2001 From: Riley Park Date: Wed, 29 Mar 2023 12:11:36 -0700 Subject: [PATCH] 8948: Nag when timings is enabled or a plugin creates a new Timing --- patches/api/Timings-v2.patch | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/patches/api/Timings-v2.patch b/patches/api/Timings-v2.patch index 8c2fbbab28..17bc99b0ea 100644 --- a/patches/api/Timings-v2.patch +++ b/patches/api/Timings-v2.patch @@ -1320,6 +1320,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + static boolean verboseEnabled = false; + private static int historyInterval = -1; + private static int historyLength = -1; ++ private static boolean warnedAboutDeprecationOnEnable; + + private Timings() {} + @@ -1354,6 +1355,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + public static Timing of(@NotNull Plugin plugin, @NotNull String name, @Nullable Timing groupHandler) { + Preconditions.checkNotNull(plugin, "Plugin can not be null"); ++ Bukkit.getLogger().warning(String.format("Plugin '%s' is creating timing '%s' - this is deprecated behavior, please report it to the authors: %s", plugin.getName(), name, String.join(", ", plugin.getDescription().getAuthors()))); + return TimingsManager.getHandler(plugin.getName(), name, groupHandler); + } + @@ -1410,9 +1412,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + public static void setTimingsEnabled(boolean enabled) { + timingsEnabled = enabled; ++ warnAboutDeprecationOnEnable(); + reset(); + } + ++ private static void warnAboutDeprecationOnEnable() { ++ if (timingsEnabled && !warnedAboutDeprecationOnEnable) { ++ Bukkit.getLogger().warning(String.join("\n", ++ "[!] The timings system has been enabled but has been scheduled for removal from Paper in the future.", ++ " We recommend installing the spark profiler as a replacement: https://spark.lucko.me/", ++ " For more information please visit: https://github.com/PaperMC/Paper/issues/8948" ++ )); ++ warnedAboutDeprecationOnEnable = true; ++ } ++ } ++ + /** + *

Sets whether or not the Timings should monitor at Verbose level.

+ *