diff options
author | feildmaster <admin@feildmaster.com> | 2012-12-27 19:22:28 -0600 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-12-29 19:18:36 -0600 |
commit | 7b5a8d0c23a23a16ce3e5317d16cb6a8f7f968c0 (patch) | |
tree | 57ccb4d609f5eae73bde1bc5b2edb362edbfa6dc /src/main | |
parent | fb0eed177a8fd6bed39571003fbc6852478c9b07 (diff) | |
download | craftbukkit-7b5a8d0c23a23a16ce3e5317d16cb6a8f7f968c0.tar craftbukkit-7b5a8d0c23a23a16ce3e5317d16cb6a8f7f968c0.tar.gz craftbukkit-7b5a8d0c23a23a16ce3e5317d16cb6a8f7f968c0.tar.lz craftbukkit-7b5a8d0c23a23a16ce3e5317d16cb6a8f7f968c0.tar.xz craftbukkit-7b5a8d0c23a23a16ce3e5317d16cb6a8f7f968c0.zip |
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.
Diffstat (limited to 'src/main')
3 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 1a0d2faa..99a8891b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -190,6 +190,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public boolean teleport(Location location, TeleportCause cause) { + if (entity.vehicle != null || entity.passenger != null || entity.dead) { + return false; + } + entity.world = ((CraftWorld) location.getWorld()).getHandle(); entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // entity.setLocation() throws no event, and so cannot be cancelled diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 8be89064..23a89b0f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -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); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 523a2f3b..90abccef 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -348,6 +348,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) { EntityPlayer entity = getHandle(); + if (getHealth() == 0 || entity.dead) { + return false; + } + if (entity.playerConnection == null || entity.playerConnection.disconnected) { return false; } |