From bb8366e41957bff34630185a9a3290718876b7e7 Mon Sep 17 00:00:00 2001 From: Dominilk01 <108392199+dominilk01@users.noreply.github.com> Date: Mon, 6 Jul 2026 20:39:39 +0200 Subject: [PATCH] Lazy initialization of formattedDisplayName --- .../world/scores/Objective.java.patch | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/scores/Objective.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/scores/Objective.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/Objective.java.patch new file mode 100644 index 000000000000..eb198effabae --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/scores/Objective.java.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/world/scores/Objective.java ++++ b/net/minecraft/world/scores/Objective.java +@@ -18,7 +_,7 @@ + private final String name; + private final ObjectiveCriteria criteria; + private Component displayName; +- private Component formattedDisplayName; ++ private @Nullable Component formattedDisplayName; // Paper - Lazy initialization because only used internally by Commands + private ObjectiveCriteria.RenderType renderType; + private boolean displayAutoUpdate; + private @Nullable NumberFormat numberFormat; +@@ -36,7 +_,6 @@ + this.name = name; + this.criteria = criteria; + this.displayName = displayName; +- this.formattedDisplayName = this.createFormattedDisplayName(); + this.renderType = renderType; + this.displayAutoUpdate = displayAutoUpdate; + this.numberFormat = numberFormat; +@@ -81,12 +_,17 @@ + } + + public Component getFormattedDisplayName() { ++ // Paper start - Lazy initialization because only used internally by Commands ++ if (this.formattedDisplayName == null) { ++ this.formattedDisplayName = this.createFormattedDisplayName(); ++ } ++ // Paper start - Lazy initialization because only used internally by Commands + return this.formattedDisplayName; + } + + public void setDisplayName(final Component name) { + this.displayName = name; +- this.formattedDisplayName = this.createFormattedDisplayName(); ++ this.formattedDisplayName = null; // Paper - Lazy initialization because only used internally by Commands + this.scoreboard.onObjectiveChanged(this); + } +