From 8c3ef5e6296ce68ed09625e812becca080a21ea9 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 1 Feb 2014 22:48:48 +0800 Subject: [PATCH] Set /npc name as persistent --- src/main/java/net/citizensnpcs/commands/NPCCommands.java | 1 + src/main/java/net/citizensnpcs/npc/CitizensNPC.java | 4 ++++ 2 files changed, 5 insertions(+) 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);