3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 21:10:10 +01:00

Use constant Player for EnderPearls

Also make sure players are online before proceeding to each event
Dieser Commit ist enthalten in:
feildmaster 2012-08-22 14:17:36 -05:00
Ursprung 98c98d0f7a
Commit 8fdb006143

Datei anzeigen

@ -32,25 +32,25 @@ public class EntityEnderPearl extends EntityProjectile {
if (!entityplayer.netServerHandler.disconnected && entityplayer.world == this.world) { if (!entityplayer.netServerHandler.disconnected && entityplayer.world == this.world) {
// CraftBukkit start // CraftBukkit start
CraftPlayer player = (CraftPlayer) this.shooter.bukkitEntity; CraftPlayer player = entityplayer.getBukkitEntity();
org.bukkit.Location location = getBukkitEntity().getLocation(); org.bukkit.Location location = getBukkitEntity().getLocation();
location.setPitch(player.getLocation().getPitch()); location.setPitch(player.getLocation().getPitch());
location.setYaw(player.getLocation().getYaw()); location.setYaw(player.getLocation().getYaw());
PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL); PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(teleEvent); 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; 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); Bukkit.getPluginManager().callEvent(damageEvent);
if (!damageEvent.isCancelled()) { if (!damageEvent.isCancelled() && !entityplayer.netServerHandler.disconnected) {
org.bukkit.entity.Player bPlayer = Bukkit.getPlayerExact(((EntityPlayer) this.shooter).name); entityplayer.invulnerableTicks = -1; // Remove spawning invulnerability
((CraftPlayer) bPlayer).getHandle().invulnerableTicks = -1; // Remove spawning invulnerability player.setLastDamageCause(damageEvent);
bPlayer.setLastDamageCause(damageEvent); entityplayer.damageEntity(DamageSource.FALL, damageEvent.getDamage());
((CraftPlayer) bPlayer).getHandle().damageEntity(DamageSource.FALL, damageEvent.getDamage()); // Damage the new player instead of the old
} }
} }
// CraftBukkit end // CraftBukkit end