diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 1a0d2faa56..99a8891b84 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 8be8906440..23a89b0f7c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 523a2f3b27..90abccefc9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/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; }