This commit is contained in:
Riley Park 2021-02-22 01:53:53 -08:00
parent 33d4f608ba
commit 511cd52f02
No known key found for this signature in database
GPG Key ID: D831AF236C834E45
2 changed files with 39 additions and 17 deletions

View File

@ -2178,10 +2178,14 @@ index 03bfca9d368bbe4b7c1353d52c883e756bf69bda..943d324435350d3f16fad3e21cb472a0
/**
diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..f46ea9f2bd4a4d9582428325e725d9220817b254 100644
index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..29c5bd1f522310def76bf7b46a5b61463d53ff96 100644
--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
+++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
@@ -17,15 +17,16 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
@@ -14,18 +14,20 @@ import org.jetbrains.annotations.NotNull;
* checked and removed by {@link #iterator() iterating} over this event.
*/
public class ServerListPingEvent extends ServerEvent implements Iterable<Player> {
+ private static final net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer LEGACY_SECTION_SERIALIZER = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.builder().useUnusualXRepeatedCharacterHexFormat().build(); // Paper
private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE;
private static final HandlerList handlers = new HandlerList();
private final InetAddress address;
@ -2196,11 +2200,11 @@ index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..f46ea9f2bd4a4d9582428325e725d922
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
this.address = address;
- this.motd = motd;
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
+ this.motd = LEGACY_SECTION_SERIALIZER.deserialize(motd); // Paper
this.numPlayers = numPlayers;
this.maxPlayers = maxPlayers;
}
@@ -38,14 +39,58 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
@@ -38,14 +40,58 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
* @param address the address of the pinger
* @param motd the message of the day
* @param maxPlayers the max number of players
@ -2211,7 +2215,7 @@ index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..f46ea9f2bd4a4d9582428325e725d922
+ super(true);
+ this.numPlayers = MAGIC_PLAYER_COUNT;
+ this.address = address;
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
+ this.motd = LEGACY_SECTION_SERIALIZER.deserialize(motd); // Paper
+ this.maxPlayers = maxPlayers;
+ }
+ // Paper start
@ -2259,7 +2263,7 @@ index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..f46ea9f2bd4a4d9582428325e725d922
/**
* Get the address the ping is coming from.
@@ -61,19 +106,23 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
@@ -61,19 +107,23 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
* Get the message of the day message.
*
* @return the message of the day
@ -2269,7 +2273,7 @@ index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..f46ea9f2bd4a4d9582428325e725d922
+ @Deprecated // Paper
public String getMotd() {
- return motd;
+ return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.motd); // Paper
+ return LEGACY_SECTION_SERIALIZER.serialize(this.motd); // Paper
}
/**
@ -2281,7 +2285,7 @@ index 7a2a58bac8e721c3f0c64f69f77be07a51f76d58..f46ea9f2bd4a4d9582428325e725d922
+ @Deprecated // Paper
public void setMotd(@NotNull String motd) {
- this.motd = motd;
+ this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper
+ this.motd = LEGACY_SECTION_SERIALIZER.deserialize(motd); // Paper
}
/**

View File

@ -60,10 +60,10 @@ index 0000000000000000000000000000000000000000..a2a409e635dde08f7c53e67164b967a0
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..26ddf92f86fccc2b2562f7abf4788d1ed6b73205
index 0000000000000000000000000000000000000000..39b236a6319b1f44fbe28bbe43f064be3073e725
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
@@ -0,0 +1,112 @@
@@ -0,0 +1,110 @@
+package com.destroystokyo.paper.network;
+
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
@ -71,16 +71,14 @@ index 0000000000000000000000000000000000000000..26ddf92f86fccc2b2562f7abf4788d1e
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
+import com.mojang.authlib.GameProfile;
+import io.papermc.paper.adventure.AdventureComponent;
+import java.util.List;
+import java.util.UUID;
+import javax.annotation.Nonnull;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.NetworkManager;
+import net.minecraft.server.PacketStatusOutServerInfo;
+import net.minecraft.server.ServerPing;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+
+import java.util.List;
+import java.util.UUID;
+
+import javax.annotation.Nonnull;
+
+public final class StandardPaperServerListPingEventImpl extends PaperServerListPingEventImpl {
+
@ -155,7 +153,7 @@ index 0000000000000000000000000000000000000000..26ddf92f86fccc2b2562f7abf4788d1e
+ ServerPing ping = new ServerPing();
+
+ // Description
+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]);
+ ping.setMOTD(new AdventureComponent(event.motd()));
+
+ // Players
+ if (!event.shouldHidePlayers()) {
@ -222,6 +220,26 @@ index 7875d4c08969b3adc6f95504686cc9fe99e3f29a..d0fad346dd4511722f958a8c0bda6749
}
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java b/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java
index 50d5fb62efa7c89c7a73ccf072a0e7e433bcc650..f81ed6cd2029bbd8bbf1ddac10851da31273e8dd 100644
--- a/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java
+++ b/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java
@@ -2,11 +2,14 @@ package net.minecraft.server;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import io.papermc.paper.adventure.AdventureComponent; // Paper
import java.io.IOException;
public class PacketStatusOutServerInfo implements Packet<PacketStatusOutListener> {
- private static final Gson a = (new GsonBuilder()).registerTypeAdapter(ServerPing.ServerData.class, new ServerPing.ServerData.Serializer()).registerTypeAdapter(ServerPing.ServerPingPlayerSample.class, new ServerPing.ServerPingPlayerSample.Serializer()).registerTypeAdapter(ServerPing.class, new ServerPing.Serializer()).registerTypeHierarchyAdapter(IChatBaseComponent.class, new IChatBaseComponent.ChatSerializer()).registerTypeHierarchyAdapter(ChatModifier.class, new ChatModifier.ChatModifierSerializer()).registerTypeAdapterFactory(new ChatTypeAdapterFactory()).create();
+ private static final Gson a = (new GsonBuilder()).registerTypeAdapter(ServerPing.ServerData.class, new ServerPing.ServerData.Serializer()).registerTypeAdapter(ServerPing.ServerPingPlayerSample.class, new ServerPing.ServerPingPlayerSample.Serializer()).registerTypeAdapter(ServerPing.class, new ServerPing.Serializer()).registerTypeHierarchyAdapter(IChatBaseComponent.class, new IChatBaseComponent.ChatSerializer()).registerTypeHierarchyAdapter(ChatModifier.class, new ChatModifier.ChatModifierSerializer()).registerTypeAdapterFactory(new ChatTypeAdapterFactory())
+ .registerTypeAdapter(AdventureComponent.class, new AdventureComponent.Serializer())
+ .create();
private ServerPing b;
public PacketStatusOutServerInfo() {}
diff --git a/src/main/java/net/minecraft/server/ServerPing.java b/src/main/java/net/minecraft/server/ServerPing.java
index aa125a52dcdf4f137cfe17c5dc808b17d5e9de0b..ea52e89bd965afbd74f15b0e2974657319c28e4a 100644
--- a/src/main/java/net/minecraft/server/ServerPing.java