Apply setLastDamageCause after processing events and the event has not been canceled. Fixes BUKKIT-1881
This allows previous causes to be available during the event, as well as making the damage cause a valid one. If EntityDamageEvent is canceled, then it's not the last DamageCause. Also prevents setting DamageCause involuntarily through construction.
Dieser Commit ist enthalten in:
Ursprung
e4e994f710
Commit
00efc8c464
@ -94,6 +94,7 @@ public class BlockCactus extends Block {
|
|||||||
world.getServer().getPluginManager().callEvent(event);
|
world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
damagee.setLastDamageCause(event);
|
||||||
entity.damageEntity(DamageSource.CACTUS, event.getDamage());
|
entity.damageEntity(DamageSource.CACTUS, event.getDamage());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -346,6 +346,7 @@ public abstract class Entity {
|
|||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.BURN, event.getDamage());
|
this.damageEntity(DamageSource.BURN, event.getDamage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -390,6 +391,7 @@ public abstract class Entity {
|
|||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
damagee.setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.LAVA, event.getDamage());
|
this.damageEntity(DamageSource.LAVA, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +274,7 @@ public abstract class EntityLiving extends Entity {
|
|||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.STUCK, event.getDamage());
|
this.damageEntity(DamageSource.STUCK, event.getDamage());
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -301,6 +302,7 @@ public abstract class EntityLiving extends Entity {
|
|||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled() && event.getDamage() != 0) {
|
if (!event.isCancelled() && event.getDamage() != 0) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.DROWN, event.getDamage());
|
this.damageEntity(DamageSource.DROWN, event.getDamage());
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -1362,6 +1364,7 @@ public abstract class EntityLiving extends Entity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.OUT_OF_WORLD, event.getDamage());
|
this.damageEntity(DamageSource.OUT_OF_WORLD, event.getDamage());
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -33,24 +33,30 @@ public class EntitySnowman extends EntityGolem {
|
|||||||
public void e() {
|
public void e() {
|
||||||
super.e();
|
super.e();
|
||||||
if (this.aT()) {
|
if (this.aT()) {
|
||||||
|
// CraftBukkit start
|
||||||
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1);
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.DROWN, event.getDamage());
|
this.damageEntity(DamageSource.DROWN, event.getDamage());
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = MathHelper.floor(this.locX);
|
int i = MathHelper.floor(this.locX);
|
||||||
int j = MathHelper.floor(this.locZ);
|
int j = MathHelper.floor(this.locZ);
|
||||||
|
|
||||||
if (this.world.getBiome(i, j).i() > 1.0F) {
|
if (this.world.getBiome(i, j).i() > 1.0F) {
|
||||||
|
// CraftBukkit start
|
||||||
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.MELTING, 1);
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.MELTING, 1);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
this.damageEntity(DamageSource.BURN, event.getDamage());
|
this.damageEntity(DamageSource.BURN, event.getDamage());
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
|
@ -144,6 +144,7 @@ public class Explosion {
|
|||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
damagee.setLastDamageCause(event);
|
||||||
entity.damageEntity(DamageSource.EXPLOSION, event.getDamage());
|
entity.damageEntity(DamageSource.EXPLOSION, event.getDamage());
|
||||||
entity.motX += d0 * d10;
|
entity.motX += d0 * d10;
|
||||||
entity.motY += d1 * d10;
|
entity.motY += d1 * d10;
|
||||||
|
@ -58,6 +58,7 @@ public class FoodMetaData {
|
|||||||
entityhuman.world.getServer().getPluginManager().callEvent(event);
|
entityhuman.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
entityhuman.damageEntity(DamageSource.STARVE, event.getDamage());
|
entityhuman.damageEntity(DamageSource.STARVE, event.getDamage());
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
@ -360,7 +360,12 @@ public class CraftEventFactory {
|
|||||||
} else {
|
} else {
|
||||||
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, damage);
|
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, damage);
|
||||||
}
|
}
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
|
callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
event.getEntity().setLastDamageCause(event);
|
||||||
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren