Don't teleport entities that are considered dead. Addresses BUKKIT-1331

Teleportation should never be processed on dead entities. If you wish
to teleport an entity, do it on a living entity. If you wish to
teleport a player, set their respawn location in PlayerRespawnEvent.
This commit is contained in:
feildmaster
2012-12-27 19:22:28 -06:00
parent fb0eed177a
commit 7b5a8d0c23
3 changed files with 18 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ import org.bukkit.entity.Projectile;
import org.bukkit.entity.SmallFireball;
import org.bukkit.entity.Snowball;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@@ -346,4 +347,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public boolean getCanPickupItems() {
return getHandle().canPickUpLoot;
}
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
if (getHealth() == 0) {
return false;
}
return super.teleport(location, cause);
}
}