From 8fdb006143f34a5bbfaadf4d1677ac7fb40403fb Mon Sep 17 00:00:00 2001 From: feildmaster Date: Wed, 22 Aug 2012 14:17:36 -0500 Subject: [PATCH] Use constant Player for EnderPearls Also make sure players are online before proceeding to each event --- .../net/minecraft/server/EntityEnderPearl.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java index d7351e66ae..dd8d722bac 100644 --- a/src/main/java/net/minecraft/server/EntityEnderPearl.java +++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java @@ -32,25 +32,25 @@ public class EntityEnderPearl extends EntityProjectile { if (!entityplayer.netServerHandler.disconnected && entityplayer.world == this.world) { // CraftBukkit start - CraftPlayer player = (CraftPlayer) this.shooter.bukkitEntity; + CraftPlayer player = entityplayer.getBukkitEntity(); org.bukkit.Location location = getBukkitEntity().getLocation(); location.setPitch(player.getLocation().getPitch()); location.setYaw(player.getLocation().getYaw()); PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); Bukkit.getPluginManager().callEvent(teleEvent); - if (!teleEvent.isCancelled()) { - ((EntityPlayer) this.shooter).netServerHandler.teleport(teleEvent.getTo()); + + if (!teleEvent.isCancelled() && !entityplayer.netServerHandler.disconnected) { + entityplayer.netServerHandler.teleport(teleEvent.getTo()); this.shooter.fallDistance = 0.0F; - EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), this.shooter.getBukkitEntity(), EntityDamageByEntityEvent.DamageCause.FALL, 5); + EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(this.getBukkitEntity(), player, EntityDamageByEntityEvent.DamageCause.FALL, 5); Bukkit.getPluginManager().callEvent(damageEvent); - if (!damageEvent.isCancelled()) { - org.bukkit.entity.Player bPlayer = Bukkit.getPlayerExact(((EntityPlayer) this.shooter).name); - ((CraftPlayer) bPlayer).getHandle().invulnerableTicks = -1; // Remove spawning invulnerability - bPlayer.setLastDamageCause(damageEvent); - ((CraftPlayer) bPlayer).getHandle().damageEntity(DamageSource.FALL, damageEvent.getDamage()); // Damage the new player instead of the old + if (!damageEvent.isCancelled() && !entityplayer.netServerHandler.disconnected) { + entityplayer.invulnerableTicks = -1; // Remove spawning invulnerability + player.setLastDamageCause(damageEvent); + entityplayer.damageEntity(DamageSource.FALL, damageEvent.getDamage()); } } // CraftBukkit end