Ignore non-living entities

This commit is contained in:
fullwall 2012-04-24 13:31:52 +08:00
parent 433c438398
commit c8415740dc

View File

@ -21,6 +21,7 @@ import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
@ -71,6 +72,8 @@ public class CitizensNPCManager implements NPCManager {
@Override @Override
public NPC getNPC(Entity entity) { public NPC getNPC(Entity entity) {
if (!(entity instanceof LivingEntity))
return null;
net.minecraft.server.Entity handle = ((CraftEntity) entity).getHandle(); net.minecraft.server.Entity handle = ((CraftEntity) entity).getHandle();
if (handle instanceof NPCHandle) if (handle instanceof NPCHandle)
return ((NPCHandle) handle).getNPC(); return ((NPCHandle) handle).getNPC();