diff --git a/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 6e4c20d2b..b7c0d38d3 100644 --- a/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -806,6 +806,7 @@ public class NPCCommands { public void name(CommandContext args, CommandSender sender, NPC npc) { LivingEntity entity = (LivingEntity) npc.getEntity(); entity.setCustomNameVisible(!entity.isCustomNameVisible()); + npc.data().setPersistent(NPC.NAMEPLATE_VISIBLE_METADATA, entity.isCustomNameVisible()); Messaging.sendTr(sender, Messages.NAMEPLATE_VISIBILITY_TOGGLED); } diff --git a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index 830fab626..5e3d1e1b3 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -220,6 +220,10 @@ public class CitizensNPC extends AbstractNPC { NMS.sendPacketNearby(getStoredLocation(), new PacketPlayOutEntityTeleport(NMS.getHandle(getEntity()))); } + + if (getEntity() instanceof LivingEntity) { + ((LivingEntity) getEntity()).setCustomNameVisible(data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true)); + } } } catch (Exception ex) { Throwable error = Throwables.getRootCause(ex);