This commit is contained in:
Camotoy 2023-02-07 13:14:06 -05:00
parent f07f532d8e
commit 6ee3d4ed96
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
3 changed files with 14 additions and 2 deletions

View File

@ -119,6 +119,8 @@ public class PlayerEntity extends LivingEntity {
setBelowNameText(objective);
}
// Update in case this entity has been despawned, then respawned
this.nametag = this.username;
// The name can't be updated later (the entity metadata for it is ignored), so we need to check for this now
updateDisplayName(session.getWorldCache().getScoreboard().getTeamFor(username));
@ -339,6 +341,8 @@ public class PlayerEntity extends LivingEntity {
this.nametag = this.username;
}
System.out.println(this.username + " " + this.nametag + " " + needsUpdate);
if (needsUpdate) {
dirtyMetadata.put(EntityData.NAMETAG, this.nametag);
}

View File

@ -352,7 +352,8 @@ public final class Scoreboard {
// With the player's lack of a team in visibility checks
updateEntityNames(remove, remove.getEntities(), true);
for (String name : remove.getEntities()) {
playerToTeam.remove(name, remove);
// 1.19.3 Mojmap Scoreboard#removePlayerTeam(PlayerTeam)
playerToTeam.remove(name);
}
session.removeCommandEnum("Geyser_Teams", remove.getId());

View File

@ -65,7 +65,14 @@ public final class Team {
if (entities.add(name)) {
added.add(name);
}
scoreboard.getPlayerToTeam().put(name, this);
scoreboard.getPlayerToTeam().compute(name, (player, oldTeam) -> {
if (oldTeam != null) {
// Remove old team from this map, and from the set of players of the old team.
// Java 1.19.3 Mojmap: Scoreboard#addPlayerToTeam calls #removePlayerFromTeam
oldTeam.entities.remove(player);
}
return this;
});
}
if (added.isEmpty()) {