From 0b41b24425a9678507a2a0c8af0067117882b837 Mon Sep 17 00:00:00 2001 From: mariaum Date: Mon, 22 Feb 2021 08:27:06 -0300 Subject: [PATCH] Fix blank names for a few seconds after spawning a npc. (#2477) --- .../java/net/citizensnpcs/npc/CitizensNPC.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index b456055f3..6a5daf5f2 100644 --- a/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -327,6 +327,7 @@ public class CitizensNPC extends AbstractNPC { } updateFlyableState(); + updateCustomNameVisibility(); updateCustomName(); Messaging.debug("Spawned", getId(), "SpawnReason." + reason); @@ -381,11 +382,7 @@ public class CitizensNPC extends AbstractNPC { updateCounter = 0; } - String nameplateVisible = data(). get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); - if (requiresNameHologram()) { - nameplateVisible = "false"; - } - getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible)); + updateCustomNameVisibility(); if (isLiving) { NMS.setKnockbackResistance((LivingEntity) getEntity(), @@ -406,6 +403,14 @@ public class CitizensNPC extends AbstractNPC { } } + private void updateCustomNameVisibility() { + String nameplateVisible = data(). get(NPC.NAMEPLATE_VISIBLE_METADATA, true).toString(); + if (requiresNameHologram()) { + nameplateVisible = "false"; + } + getEntity().setCustomNameVisible(Boolean.parseBoolean(nameplateVisible)); + } + private void updateCustomName() { boolean nameVisibility = false; if (!getEntity().isCustomNameVisible()