mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix edge case in removing below name objectives
This commit is contained in:
parent
86c0c009e7
commit
b58cbd00bc
2 changed files with 6 additions and 6 deletions
|
@ -355,7 +355,9 @@ public class PlayerEntity extends LivingEntity {
|
||||||
session.sendUpstreamPacket(packet);
|
session.sendUpstreamPacket(packet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (valid && metadata.remove(EntityData.SCORE_TAG) != null) {
|
// Always remove the score tag first, then check for valid.
|
||||||
|
// That way the score tag is removed if the player was spawned, then despawned, and is being respawned
|
||||||
|
if (metadata.remove(EntityData.SCORE_TAG) != null && valid) {
|
||||||
SetEntityDataPacket packet = new SetEntityDataPacket();
|
SetEntityDataPacket packet = new SetEntityDataPacket();
|
||||||
packet.setRuntimeEntityId(geyserId);
|
packet.setRuntimeEntityId(geyserId);
|
||||||
packet.getMetadata().put(EntityData.SCORE_TAG, "");
|
packet.getMetadata().put(EntityData.SCORE_TAG, "");
|
||||||
|
|
|
@ -70,11 +70,9 @@ public class JavaScoreboardObjectiveTranslator extends PacketTranslator<ServerSc
|
||||||
if (objective != null && objective == scoreboard.getObjectiveSlots().get(ScoreboardPosition.BELOW_NAME)) {
|
if (objective != null && objective == scoreboard.getObjectiveSlots().get(ScoreboardPosition.BELOW_NAME)) {
|
||||||
// Clear the score tag from all players
|
// Clear the score tag from all players
|
||||||
for (PlayerEntity entity : session.getEntityCache().getAllPlayerEntities()) {
|
for (PlayerEntity entity : session.getEntityCache().getAllPlayerEntities()) {
|
||||||
if (!entity.isValid()) {
|
// Other places we check for the entity being valid,
|
||||||
// Player hasn't spawned yet - don't bother
|
// but we must set the below name text as null for all players
|
||||||
continue;
|
// or else PlayerEntity#spawnEntity will find a null objective and not touch EntityData#SCORE_TAG
|
||||||
}
|
|
||||||
|
|
||||||
entity.setBelowNameText(session, null);
|
entity.setBelowNameText(session, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue