9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0111-Vanilla-player-display-name.patch
MC_XiaoHei 90080d238e 1.21.10 (#752)
---------

Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
2025-11-28 03:15:54 +08:00

56 lines
3.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
Date: Sun, 30 Mar 2025 21:53:45 +0800
Subject: [PATCH] Vanilla player display name
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 44b1d56fb3ce3827290ef4cf987aa2386d07eb9c..77f82c8bf2ffbe642f1149aa4a5269818964296a 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -491,7 +491,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
this.object = null;
// CraftBukkit start
this.displayName = this.getScoreboardName();
- this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
+ this.adventure$displayName = org.leavesmc.leaves.LeavesConfig.fix.vanillaDisplayName ? io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getDisplayName()) : net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper // Leaves - vanilla display name
this.bukkitPickUpLoot = true;
this.maxHealthCache = this.getMaxHealth();
// CraftBukkit end
diff --git a/net/minecraft/world/scores/Scoreboard.java b/net/minecraft/world/scores/Scoreboard.java
index e25075f6436a8020bd1b0d9e53ed93d0eb914d6a..e20fe2d12b28e108763156781444a59a9dbdc25d 100644
--- a/net/minecraft/world/scores/Scoreboard.java
+++ b/net/minecraft/world/scores/Scoreboard.java
@@ -282,6 +282,16 @@ public class Scoreboard {
}
this.teamsByPlayer.put(playerName, team);
+ // Leaves start - vanilla display name
+ if (org.leavesmc.leaves.LeavesConfig.fix.vanillaDisplayName) {
+ boolean result = team.getPlayers().add(playerName);
+ net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(playerName);
+ if (player != null) {
+ player.adventure$displayName = io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName());
+ }
+ return result;
+ }
+ // Leaves end - vanilla display name
return team.getPlayers().add(playerName);
}
@@ -301,6 +311,14 @@ public class Scoreboard {
} else {
this.teamsByPlayer.remove(playerName);
team.getPlayers().remove(playerName);
+ // Leaves start - vanilla display name
+ if (org.leavesmc.leaves.LeavesConfig.fix.vanillaDisplayName) {
+ net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(playerName);
+ if (player != null) {
+ player.adventure$displayName = io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName());
+ }
+ }
+ // Leaves end - vanilla display name
}
}