Updated Upstream (Paper)

Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@46a9d2a Cache Component MOTDs
This commit is contained in:
BillyGalbreath
2022-07-22 22:01:21 -05:00
parent a60a01188e
commit e65c695fc5
13 changed files with 75 additions and 73 deletions

View File

@@ -3,36 +3,38 @@ From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Fri, 22 Jul 2022 20:33:58 -0500
Subject: [PATCH] Cache server motd
Paper ported my patch in an odd way. Keeping my patch around to reduce logic on the motd getter
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2ece154b5e7daaa3e0b128145fc5e1d452125f72..7175c21e8094206f5fd33bdccd417613bdddffa3 100644
index 8dafcaeabd3fb371736fee7fe15e78d544455c04..6e8055d70695841d21654b4f72643b4d0ea42867 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1885,7 +1885,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -232,7 +232,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
private boolean allowFlight;
@Nullable
private String motd;
- @Nullable private net.kyori.adventure.text.Component cachedMotd; // Paper
+ private net.kyori.adventure.text.Component cachedMotd = net.kyori.adventure.text.Component.empty(); // Paper // Purpur
private int playerIdleTimeout;
public final long[] tickTimes;
// Paper start
@@ -1885,17 +1885,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
public net.kyori.adventure.text.Component getComponentMotd() {
- net.kyori.adventure.text.Component component = cachedMotd;
- if (this.motd != null && this.cachedMotd == null) {
- component = cachedMotd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(this.motd);
- }
-
- return component != null ? component : net.kyori.adventure.text.Component.empty();
+ return this.cachedMotd; // Purpur
}
public void setMotd(String motd) {
this.motd = motd;
+ // Purpur start
+ this.motdComponent = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd);
+ }
+ public net.kyori.adventure.text.Component motd() {
+ return this.motdComponent;
- this.cachedMotd = null; // Paper
+ this.cachedMotd = motd == null ? net.kyori.adventure.text.Component.empty() : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper // Purpur
}
+ private net.kyori.adventure.text.Component motdComponent;
+ // Purpur end
public boolean previewsChat() {
return false;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7208236ee3c604620fd0d0afe49215320e45e24b..ccd410d2fa62ab9f868f5d25d1a7418e4e6c485c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2236,7 +2236,7 @@ public final class CraftServer implements Server {
// Paper start
@Override
public net.kyori.adventure.text.Component motd() {
- return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(console.getMotd());
+ return console.motd(); // Purpur
}
// Paper end
@Override