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/0113-Vanilla-player-display-name.patch
2025-08-16 22:08:16 +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 e9e98636f4e8665fb83d726a701e5d99ba3b992d..b10ae364db96856007ca2fdd37124c77a1f3df14 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -476,7 +476,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 4275d048a8f5e98c7436f5bf2d55a9b68f7ba818..c68399f1ada71f6b301b41bdc83af024a9d2f1d3 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(username);
playerTeam.getPlayers().remove(username);
+ // 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(username);
+ if (player != null) {
+ player.adventure$displayName = io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName());
+ }
+ }
+ // Leaves end - vanilla display name
}
}