From d6d0bad512f2adaa9da6e1bdd29b76b7caf0451e Mon Sep 17 00:00:00 2001 From: Riley Park Date: Wed, 29 Mar 2023 19:11:50 -0700 Subject: [PATCH] Turn deprecation message into a `Component` to be used in the command at a later date --- patches/api/Timings-v2.patch | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/patches/api/Timings-v2.patch b/patches/api/Timings-v2.patch index 17bc99b0ea..c3432f8260 100644 --- a/patches/api/Timings-v2.patch +++ b/patches/api/Timings-v2.patch @@ -1296,6 +1296,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import com.google.common.base.Preconditions; +import com.google.common.collect.EvictingQueue; +import com.google.common.collect.Lists; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.event.ClickEvent; ++import net.kyori.adventure.text.format.TextColor; ++import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; @@ -1418,15 +1422,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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" -+ )); ++ Bukkit.getLogger().warning(PlainTextComponentSerializer.plainText().serialize(deprecationMessage())); + warnedAboutDeprecationOnEnable = true; + } + } + ++ public static Component deprecationMessage() { ++ return Component.text() ++ .color(TextColor.color(0xf3ef91)) ++ .append(Component.text("[!] The timings profiler has been enabled but has been scheduled for removal from Paper in the future.")) ++ .append(Component.newline()) ++ .append( ++ Component.text(" We recommend installing the spark profiler as a replacement: ") ++ .append( ++ Component.text() ++ .content("https://spark.lucko.me/") ++ .clickEvent(ClickEvent.openUrl("https://spark.lucko.me/"))) ++ ) ++ .append(Component.newline()) ++ .append(Component.text(" For more information please visit: https://github.com/PaperMC/Paper/issues/8948")) ++ .build(); ++ } ++ + /** + *

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

+ * @@ -1644,6 +1661,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!testPermission(sender)) { + return true; + } ++ if (false) { ++ sender.sendMessage(Timings.deprecationMessage()); ++ } + if (args.length < 1) { + sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED)); + return true;