Deprecate ChatColor (#9069)

All API that uses it is deprecated
This commit is contained in:
Jake Potrebic
2023-04-02 11:53:29 -07:00
parent 7d091ee970
commit 74b88dc367
7 changed files with 87 additions and 12 deletions

View File

@@ -13,9 +13,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+package com.destroystokyo.paper.network;
+
+import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
+import net.minecraft.ChatFormatting;
+import net.minecraft.server.MinecraftServer;
+import org.apache.commons.lang3.StringUtils;
+import org.bukkit.ChatColor;
+
+import java.net.InetSocketAddress;
+
@@ -68,13 +69,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return event;
+ }
+
+ @SuppressWarnings("deprecation") // Valid as this is the legacy status client
+ public static String getMotd(PaperServerListPingEvent event) {
+ return getFirstLine(event.getMotd());
+ }
+
+ public static String getUnformattedMotd(PaperServerListPingEvent event) {
+ // Strip color codes and all other occurrences of the color char (because it's used as delimiter)
+ return getFirstLine(StringUtils.remove(ChatColor.stripColor(event.getMotd()), ChatColor.COLOR_CHAR));
+ return getFirstLine(StringUtils.remove(PlainTextComponentSerializer.plainText().serialize(event.motd()), ChatFormatting.PREFIX_CODE));
+ }
+
+ private static String getFirstLine(String s) {