Retiring EntityDamageByProjectileEvent in favor of EntityDamageEvent.
Dieser Commit ist enthalten in:
Ursprung
e2e4d7f4ca
Commit
7d4ec8b183
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
if (event.isCancelled() || event.getDamage() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
i = event.getDamage();
|
||||
}
|
||||
|
||||
i = event.getDamage();
|
||||
// CraftBukkit end
|
||||
|
||||
this.a((EntityLiving) object, false);
|
||||
|
@ -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);
|
||||
|
23
src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
Normale Datei
23
src/main/java/org/bukkit/craftbukkit/entity/AbstractProjectile.java
Normale Datei
@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Projectile;
|
||||
|
||||
public abstract class AbstractProjectile extends CraftEntity implements Projectile {
|
||||
|
||||
private boolean doesBounce;
|
||||
|
||||
public AbstractProjectile(CraftServer server, net.minecraft.server.Entity entity) {
|
||||
super(server, entity);
|
||||
doesBounce = false;
|
||||
}
|
||||
|
||||
public boolean doesBounce() {
|
||||
return doesBounce;
|
||||
}
|
||||
|
||||
public void setBounce(boolean doesBounce) {
|
||||
this.doesBounce = doesBounce;
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,8 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class CraftArrow extends CraftEntity implements Arrow {
|
||||
public class CraftArrow extends AbstractProjectile implements Arrow {
|
||||
|
||||
public CraftArrow(CraftServer server, EntityArrow entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class CraftEgg extends CraftEntity implements Egg {
|
||||
public class CraftEgg extends AbstractProjectile implements Egg {
|
||||
|
||||
public CraftEgg(CraftServer server, EntityEgg entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftFireball extends CraftEntity implements Fireball {
|
||||
public class CraftFireball extends AbstractProjectile implements Fireball {
|
||||
public CraftFireball(CraftServer server, EntityFireball entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class CraftFish extends CraftEntity implements Fish {
|
||||
public class CraftFish extends AbstractProjectile implements Fish {
|
||||
public CraftFish(CraftServer server, EntityFish entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Snowball;
|
||||
|
||||
public class CraftSnowball extends CraftEntity implements Snowball {
|
||||
public class CraftSnowball extends AbstractProjectile implements Snowball {
|
||||
public CraftSnowball(CraftServer server, EntitySnowball entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren