summaryrefslogtreecommitdiffstats
path: root/src/main/java/net
diff options
context:
space:
mode:
authorsunkid <sunkid@iminurnetz.com>2011-07-19 13:26:00 -0700
committerEvilSeph <evilseph@gmail.com>2011-07-28 01:51:09 -0400
commit7d4ec8b1835648a2108a46480a3c2fd9e846fa0c (patch)
tree062e0f584240b75998bd3f8f6bae96f2880bfc9c /src/main/java/net
parente2e4d7f4ca1d0a3c5948304343942f11cac340a9 (diff)
downloadcraftbukkit-7d4ec8b1835648a2108a46480a3c2fd9e846fa0c.tar
craftbukkit-7d4ec8b1835648a2108a46480a3c2fd9e846fa0c.tar.gz
craftbukkit-7d4ec8b1835648a2108a46480a3c2fd9e846fa0c.tar.lz
craftbukkit-7d4ec8b1835648a2108a46480a3c2fd9e846fa0c.tar.xz
craftbukkit-7d4ec8b1835648a2108a46480a3c2fd9e846fa0c.zip
Retiring EntityDamageByProjectileEvent in favor of EntityDamageEvent.
Diffstat (limited to 'src/main/java/net')
-rw-r--r--src/main/java/net/minecraft/server/EntityArrow.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityEgg.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityFireball.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityFish.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java21
-rw-r--r--src/main/java/net/minecraft/server/EntitySnowball.java8
6 files changed, 33 insertions, 28 deletions
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index 69d40dfe..3e31abd8 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -5,7 +5,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
@@ -179,15 +179,15 @@ public class EntityArrow extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO deal with arrows being fired from a non-entity
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 4);
server.getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the arrow should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 4);
diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java
index 58a204d7..50441dbb 100644
--- a/src/main/java/net/minecraft/server/EntityEgg.java
+++ b/src/main/java/net/minecraft/server/EntityEgg.java
@@ -6,7 +6,7 @@ import java.util.List;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
@@ -161,14 +161,14 @@ public class EntityEgg extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the egg should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.thrower, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.thrower, 0);
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
index a025cbdb..7b7335b8 100644
--- a/src/main/java/net/minecraft/server/EntityFireball.java
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Explosive;
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
@@ -141,16 +141,16 @@ public class EntityFireball extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the fireball should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java
index ed704a9c..ff63566d 100644
--- a/src/main/java/net/minecraft/server/EntityFish.java
+++ b/src/main/java/net/minecraft/server/EntityFish.java
@@ -4,7 +4,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerFishEvent;
// CraftBukkit end
@@ -197,14 +197,14 @@ public class EntityFish extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the fish should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.owner, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.owner, 0);
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index f8e31db2..d2fa3db1 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -7,6 +7,7 @@ import java.util.List;
import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.craftbukkit.TrigMath;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
@@ -416,17 +417,21 @@ public abstract class EntityHuman extends EntityLiving {
if (object instanceof EntityLiving) {
// CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters
// also damage the player in this way. For example, EntitySlime.
- org.bukkit.entity.Entity damager = ((Entity) object).getBukkitEntity();
- org.bukkit.entity.Entity damagee = this.getBukkitEntity();
- EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
- this.world.getServer().getPluginManager().callEvent(event);
+ // We handle projectiles in their individual classes!
+ if (!(entity.getBukkitEntity() instanceof Projectile)) {
+ org.bukkit.entity.Entity damager = ((Entity) object).getBukkitEntity();
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
- if (event.isCancelled() || event.getDamage() == 0) {
- return false;
- }
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
+ this.world.getServer().getPluginManager().callEvent(event);
- i = event.getDamage();
+ if (event.isCancelled() || event.getDamage() == 0) {
+ return false;
+ }
+
+ i = event.getDamage();
+ }
// CraftBukkit end
this.a((EntityLiving) object, false);
diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java
index d1e66f8c..d89221a8 100644
--- a/src/main/java/net/minecraft/server/EntitySnowball.java
+++ b/src/main/java/net/minecraft/server/EntitySnowball.java
@@ -5,7 +5,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile;
-import org.bukkit.event.entity.EntityDamageByProjectileEvent;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
// CraftBukkit end
@@ -159,15 +159,15 @@ public class EntitySnowball extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
if (event.isCancelled()) {
- stick = !event.getBounce();
+ stick = !projectile.doesBounce();
} else {
// this function returns if the snowball should stick in or not, i.e. !bounce
- stick = movingobjectposition.entity.damageEntity(this.shooter, event.getDamage());
+ stick = movingobjectposition.entity.damageEntity(this, event.getDamage());
}
} else {
stick = movingobjectposition.entity.damageEntity(this.shooter, 0);