[Bleeding] Moved projectile EntityDamageByEntityEvent's to event factory. Addresses BUKKIT-775
This commit is contained in:
@@ -6,8 +6,6 @@ import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
// CraftBukkit end
|
||||
@@ -169,7 +167,8 @@ public class EntityArrow extends Entity {
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
// CraftBukkit start
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
|
||||
this.world.getServer().getPluginManager().callEvent(phe);
|
||||
// CraftBukkit end
|
||||
if (movingobjectposition.entity != null) {
|
||||
@@ -198,28 +197,8 @@ public class EntityArrow extends Entity {
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
boolean stick;
|
||||
if (entity instanceof EntityLiving || entity instanceof EntityComplexPart) {
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !projectile.doesBounce();
|
||||
} else {
|
||||
// this function returns if the arrow should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(damagesource, event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(damagesource, l);
|
||||
}
|
||||
|
||||
if (stick) {
|
||||
// CraftBukkit end
|
||||
// CraftBukkit - entity.damageEntity -> event function
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent(projectile, entity, damagesource, l)) {
|
||||
if (movingobjectposition.entity instanceof EntityLiving) {
|
||||
++((EntityLiving) movingobjectposition.entity).aJ;
|
||||
if (this.n > 0) {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntityEgg extends EntityProjectile {
|
||||
|
||||
@@ -27,25 +25,7 @@ public class EntityEgg extends EntityProjectile {
|
||||
protected void a(MovingObjectPosition movingobjectposition) {
|
||||
// CraftBukkit start
|
||||
if (movingobjectposition.entity != null) {
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving || movingobjectposition.entity instanceof EntityComplexPart) {
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !projectile.doesBounce();
|
||||
} else {
|
||||
// this function returns if the egg should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0);
|
||||
}
|
||||
|
||||
if (stick) {
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity, DamageSource.projectile(this, this.shooter), 0)) {
|
||||
; // Original code does nothing *yet*
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,9 @@ package net.minecraft.server;
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.entity.Explosive;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
// CraftBukkit end
|
||||
@@ -181,30 +178,14 @@ public class EntityFireball extends Entity {
|
||||
protected void a(MovingObjectPosition movingobjectposition) {
|
||||
if (!this.world.isStatic) {
|
||||
// CraftBukkit start
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
|
||||
this.world.getServer().getPluginManager().callEvent(phe);
|
||||
// CraftBukkit end
|
||||
if (!this.world.isStatic) {
|
||||
// CraftBukkit start
|
||||
if (movingobjectposition.entity != null) {
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving || movingobjectposition.entity instanceof EntityComplexPart) {
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !projectile.doesBounce();
|
||||
} else {
|
||||
// this function returns if the fireball should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 0);
|
||||
}
|
||||
if (stick) {
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent(projectile, movingobjectposition.entity, DamageSource.projectile(this, this.shooter), 0)) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,7 @@ package net.minecraft.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
// CraftBukkit end
|
||||
import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
|
||||
|
||||
public class EntityFishingHook extends Entity {
|
||||
|
||||
@@ -190,26 +184,8 @@ public class EntityFishingHook extends Entity {
|
||||
|
||||
if (movingobjectposition != null) {
|
||||
if (movingobjectposition.entity != null) {
|
||||
// CraftBukkit start
|
||||
boolean stick;
|
||||
if (movingobjectposition.entity instanceof EntityLiving || movingobjectposition.entity instanceof EntityComplexPart) {
|
||||
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !projectile.doesBounce();
|
||||
} else {
|
||||
// this function returns if the fish should stick in or not, i.e. !bounce
|
||||
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0);
|
||||
}
|
||||
if (!stick) {
|
||||
// CraftBukkit end
|
||||
// CraftBukkit - entity.damageEntity -> event function
|
||||
if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity, DamageSource.projectile(this, this.owner), 0)) {
|
||||
this.hooked = movingobjectposition.entity;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -4,8 +4,6 @@ package net.minecraft.server;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
// CraftBukkit end
|
||||
@@ -25,7 +23,8 @@ public class EntitySmallFireball extends EntityFireball {
|
||||
protected void a(MovingObjectPosition movingobjectposition) {
|
||||
if (!this.world.isStatic) {
|
||||
// CraftBukkit start - projectile hit event
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
|
||||
final PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.callEvent(phe);
|
||||
// CraftBukkit end
|
||||
@@ -33,25 +32,9 @@ public class EntitySmallFireball extends EntityFireball {
|
||||
if (movingEntity != null) {
|
||||
// CraftBukkit start - entity damage by entity event + combust event
|
||||
if (!movingEntity.isFireproof()) { // check if not fireproof
|
||||
boolean stick;
|
||||
org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
|
||||
if (movingEntity instanceof EntityLiving || movingEntity instanceof EntityComplexPart) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 5);
|
||||
pluginManager.callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !projectile.doesBounce();
|
||||
} else {
|
||||
// this function returns if the fireball should stick in or not, i.e. !bounce
|
||||
stick = movingEntity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage());
|
||||
}
|
||||
} else {
|
||||
stick = movingEntity.damageEntity(DamageSource.fireball(this, this.shooter), 5);
|
||||
}
|
||||
|
||||
if (stick) {
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent(projectile, movingobjectposition.entity, DamageSource.projectile(this, this.shooter), 0)) {
|
||||
// if the fireball 'sticks', ignite the target
|
||||
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(projectile, damagee, 5);
|
||||
pluginManager.callEvent(combustEvent);
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntitySnowball extends EntityProjectile {
|
||||
|
||||
public EntitySnowball(World world) {
|
||||
@@ -29,33 +21,8 @@ public class EntitySnowball extends EntityProjectile {
|
||||
if (movingobjectposition.entity instanceof EntityBlaze) {
|
||||
b0 = 3;
|
||||
}
|
||||
// CraftBukkit start
|
||||
final Entity movingEntity = movingobjectposition.entity;
|
||||
boolean stick = false;
|
||||
|
||||
if (movingEntity != null) {
|
||||
if (movingEntity instanceof EntityLiving || movingEntity instanceof EntityComplexPart) {
|
||||
org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
|
||||
Projectile projectile = (Projectile) this.getBukkitEntity();
|
||||
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
|
||||
b0 = event.getDamage();
|
||||
|
||||
if (event.isCancelled()) {
|
||||
stick = !projectile.doesBounce();
|
||||
} else {
|
||||
// this function returns if the snowball should stick in or not, i.e. !bounce
|
||||
stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
|
||||
}
|
||||
} else {
|
||||
stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
|
||||
}
|
||||
}
|
||||
|
||||
if (stick) {
|
||||
// CraftBukkit end
|
||||
// CraftBukkit - entity.damageEntity -> event function
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleProjectileEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity, DamageSource.projectile(this, this.shooter), b0)) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user