This commit is contained in:
Riley Park 2021-02-22 01:53:53 -08:00
parent e1763a2679
commit 7b8399ab04
2 changed files with 34 additions and 12 deletions

View File

@ -2181,7 +2181,11 @@ diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/sr
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java --- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
+++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
@@ -0,0 +0,0 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player> @@ -0,0 +0,0 @@ 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 int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE;
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final InetAddress address; private final InetAddress address;
@ -2196,7 +2200,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
this.address = address; this.address = address;
- this.motd = 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
this.numPlayers = numPlayers; this.numPlayers = numPlayers;
this.maxPlayers = maxPlayers; this.maxPlayers = maxPlayers;
} }
@ -2211,7 +2215,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ super(true); + super(true);
+ this.numPlayers = MAGIC_PLAYER_COUNT; + this.numPlayers = MAGIC_PLAYER_COUNT;
+ this.address = address; + 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; + this.maxPlayers = maxPlayers;
+ } + }
+ // Paper start + // Paper start
@ -2269,7 +2273,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public String getMotd() { public String getMotd() {
- return motd; - 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 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setMotd(@NotNull String motd) { public void setMotd(@NotNull String motd) {
- this.motd = 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

@ -71,16 +71,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings; +import com.google.common.base.Strings;
+import com.mojang.authlib.GameProfile; +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.MinecraftServer;
+import net.minecraft.server.NetworkManager; +import net.minecraft.server.NetworkManager;
+import net.minecraft.server.PacketStatusOutServerInfo; +import net.minecraft.server.PacketStatusOutServerInfo;
+import net.minecraft.server.ServerPing; +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 { +public final class StandardPaperServerListPingEventImpl extends PaperServerListPingEventImpl {
+ +
@ -155,7 +153,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ServerPing ping = new ServerPing(); + ServerPing ping = new ServerPing();
+ +
+ // Description + // Description
+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]); + ping.setMOTD(new AdventureComponent(event.motd()));
+ +
+ // Players + // Players
+ if (!event.shouldHidePlayers()) { + if (!event.shouldHidePlayers()) {
@ -222,6 +220,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// CraftBukkit end // CraftBukkit end
} }
diff --git a/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java b/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java
+++ b/src/main/java/net/minecraft/server/PacketStatusOutServerInfo.java
@@ -0,0 +0,0 @@ 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 diff --git a/src/main/java/net/minecraft/server/ServerPing.java b/src/main/java/net/minecraft/server/ServerPing.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/ServerPing.java --- a/src/main/java/net/minecraft/server/ServerPing.java