@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user