Archiviert
13
0

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.
Dieser Commit ist enthalten in:
feildmaster 2012-12-27 19:22:28 -06:00
Ursprung fb0eed177a
Commit 7b5a8d0c23
3 geänderte Dateien mit 18 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -190,6 +190,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
public boolean teleport(Location location, TeleportCause cause) { 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.world = ((CraftWorld) location.getWorld()).getHandle();
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// entity.setLocation() throws no event, and so cannot be cancelled // entity.setLocation() throws no event, and so cannot be cancelled

Datei anzeigen

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

Datei anzeigen

@ -348,6 +348,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) { public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
EntityPlayer entity = getHandle(); EntityPlayer entity = getHandle();
if (getHealth() == 0 || entity.dead) {
return false;
}
if (entity.playerConnection == null || entity.playerConnection.disconnected) { if (entity.playerConnection == null || entity.playerConnection.disconnected) {
return false; return false;
} }