diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-01 23:34:14 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-01 23:34:14 +0000 |
commit | 0c958c0dff372398a773c3ebc52f5178bce0f374 (patch) | |
tree | ddbb4f9f572eb66e38ac5e71dbfb4298142c2cfb /src/main/java/net | |
parent | 6f79ca5c54d30d04803143975757713a01bf4e35 (diff) | |
download | craftbukkit-0c958c0dff372398a773c3ebc52f5178bce0f374.tar craftbukkit-0c958c0dff372398a773c3ebc52f5178bce0f374.tar.gz craftbukkit-0c958c0dff372398a773c3ebc52f5178bce0f374.tar.lz craftbukkit-0c958c0dff372398a773c3ebc52f5178bce0f374.tar.xz craftbukkit-0c958c0dff372398a773c3ebc52f5178bce0f374.zip |
Fixed exploit with Ender Pearls, and made them perform a damage event. This fixes BUKKIT-38
Diffstat (limited to 'src/main/java/net')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityEnderPearl.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java new file mode 100644 index 00000000..02e0327e --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java @@ -0,0 +1,52 @@ +package net.minecraft.server; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.event.entity.EntityDamageEvent; + +public class EntityEnderPearl extends EntityProjectile { + public EntityEnderPearl(World world) { + super(world); + } + + public EntityEnderPearl(World world, EntityLiving entityliving) { + super(world, entityliving); + } + + public EntityEnderPearl(World world, double d0, double d1, double d2) { + super(world, d0, d1, d2); + } + + protected void a(MovingObjectPosition movingobjectposition) { + if (movingobjectposition.entity != null && movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0)) { + ; + } + + for (int i = 0; i < 32; ++i) { + this.world.a("portal", this.locX, this.locY + this.random.nextDouble() * 2.0D, this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian()); + } + + if (!this.world.isStatic) { + // CraftBukkit start - dupe fix + damage event + boolean damage = false; + if (this.shooter != null) { + if (this.shooter instanceof EntityPlayer) { + damage = ((CraftPlayer)this.shooter.bukkitEntity).isOnline(); + } else { + damage = true; + } + } + + if (damage) { + this.shooter.a_(this.locX, this.locY, this.locZ); + this.shooter.fallDistance = 0.0F; + EntityDamageEvent event = new EntityDamageEvent(getBukkitEntity(), EntityDamageEvent.DamageCause.FALL, 5); + Bukkit.getPluginManager().callEvent(event); + this.shooter.damageEntity(DamageSource.FALL, event.getDamage()); + } + // CraftBukkit end + + this.die(); + } + } +} |