Fix /npc name for 1.8 protocol

This commit is contained in:
fullwall 2014-11-26 13:41:24 +08:00
parent 15e157b676
commit 2dfa2e660f

View File

@ -28,6 +28,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
@ -240,6 +241,13 @@ public class CitizensNPC extends AbstractNPC {
if (getEntity() instanceof LivingEntity) {
((LivingEntity) getEntity()).setCustomNameVisible(data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true));
try {
((CraftLivingEntity) getEntity()).getHandle().getDataWatcher()
.watch(3, data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true) ? 1 : 0);
} catch (NullPointerException e) {
((CraftLivingEntity) getEntity()).getHandle().getDataWatcher()
.a(3, data().get(NPC.NAMEPLATE_VISIBLE_METADATA, true) ? 1 : 0);
}
}
}
} catch (Exception ex) {