Files
Purpur/patches/server/0287-Cache-server-motd.patch
BillyGalbreath 28e3713086 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@a15152e Allow old behavior for CommandRegisteredEvent (#8249)
PaperMC/Paper@0118c0b Improve MojangAPI docs and replace @Deprecated with @ApiStatus.Experimental on draft APIs (#8261)
PaperMC/Paper@3624637 Improve documentation of Inventory#removeItem (#8263)
PaperMC/Paper@a47301e Fix Player#chat kicking all clients (#8262)
PaperMC/Paper@78b19f8 Separate Command Sending to Separate Thread Pool (#8170)
2022-08-08 09:23:12 -05:00

41 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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 100460d26fbb645a138f1883335ce7838b243a19..1c77d96f51e32fff7907f372f2303266cb6d0c77 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -234,7 +234,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
@@ -1886,17 +1886,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;
- 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
}
public boolean previewsChat() {