3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 02:50:09 +01:00

Turn deprecation message into a Component to be used in the command at a later date

Dieser Commit ist enthalten in:
Riley Park 2023-03-29 19:11:50 -07:00
Ursprung 32875b429a
Commit a13759afcc

Datei anzeigen

@ -1264,10 +1264,10 @@ index 0000000000000000000000000000000000000000..df142a89b8c43acb81eb383eac0ef048
+}
diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java
new file mode 100644
index 0000000000000000000000000000000000000000..c5ae86919e7ad8cc902405e34ddca633d6354e6b
index 0000000000000000000000000000000000000000..986d4e077759098bd49b76968d1600f99e26a13b
--- /dev/null
+++ b/src/main/java/co/aikar/timings/Timings.java
@@ -0,0 +1,314 @@
@@ -0,0 +1,331 @@
+/*
+ * This file is licensed under the MIT License (MIT).
+ *
@ -1296,6 +1296,10 @@ index 0000000000000000000000000000000000000000..c5ae86919e7ad8cc902405e34ddca633
+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..c5ae86919e7ad8cc902405e34ddca633
+
+ 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();
+ }
+
+ /**
+ * <p>Sets whether or not the Timings should monitor at Verbose level.</p>
+ *
@ -1584,10 +1601,10 @@ index 0000000000000000000000000000000000000000..c5ae86919e7ad8cc902405e34ddca633
+
diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..61cfad5cd53980836e1fd6ecf08a760166fff2b9
index 0000000000000000000000000000000000000000..e801e79fa57c44b2e5d359647c920f88064826f1
--- /dev/null
+++ b/src/main/java/co/aikar/timings/TimingsCommand.java
@@ -0,0 +1,121 @@
@@ -0,0 +1,124 @@
+/*
+ * This file is licensed under the MIT License (MIT).
+ *
@ -1644,6 +1661,9 @@ index 0000000000000000000000000000000000000000..61cfad5cd53980836e1fd6ecf08a7601
+ 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;