Set /npc name as persistent

This commit is contained in:
fullwall 2014-02-01 22:48:48 +08:00
parent db88b84c97
commit 8c3ef5e629
2 changed files with 5 additions and 0 deletions

View File

@ -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);
}

View File

@ -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);