Workaround for metadata issue

This commit is contained in:
fullwall 2012-09-12 21:18:47 +08:00
parent 136161c18e
commit 9b1a53fcab

View File

@ -2,6 +2,7 @@ package net.citizensnpcs.npc.entity;
import java.io.IOException;
import java.net.Socket;
import java.util.List;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
@ -20,6 +21,11 @@ import net.minecraft.server.NetHandler;
import net.minecraft.server.NetworkManager;
import net.minecraft.server.World;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
@ -71,6 +77,35 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
return npc;
}
@Override
public CraftPlayer getBukkitEntity() {
if (npc == null)
return super.getBukkitEntity();
if (bukkitEntity != null)
return (CraftPlayer) bukkitEntity;
return (CraftPlayer) (bukkitEntity = new CraftPlayer(((CraftServer) Bukkit.getServer()), this) {
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
server.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);
}
@Override
public List<MetadataValue> getMetadata(String metadataKey) {
return server.getEntityMetadata().getMetadata(this, metadataKey);
}
@Override
public boolean hasMetadata(String metadataKey) {
return server.getEntityMetadata().hasMetadata(this, metadataKey);
}
@Override
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
server.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
});
}
@Override
public void h_() {
super.h_();