SPIGOT-5290: Invulnerable and/or Marker armor stand triggers EntityDamageEvent

This commit is contained in:
anhcraft 2019-08-28 18:02:43 +07:00 committed by md_5
parent 631eaeb09b
commit 6ed8a18966

View file

@ -52,21 +52,24 @@
if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
itemstack2 = itemstack.cloneItemStack(); itemstack2 = itemstack.cloneItemStack();
@@ -396,14 +427,19 @@ @@ -398,12 +429,22 @@
@Override
public boolean damageEntity(DamageSource damagesource, float f) { public boolean damageEntity(DamageSource damagesource, float f) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
if (!this.world.isClientSide && !this.dead) { if (!this.world.isClientSide && !this.dead) {
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
- this.die(); - this.die();
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
return false; return false;
} else if (!this.isInvulnerable(damagesource) && !this.bD && !this.isMarker()) { } else if (!this.isInvulnerable(damagesource) && !this.bD && !this.isMarker()) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
if (damagesource.isExplosion()) { if (damagesource.isExplosion()) {
this.g(damagesource); this.g(damagesource);
- this.die(); - this.die();
@ -74,7 +77,7 @@
return false; return false;
} else if (DamageSource.FIRE.equals(damagesource)) { } else if (DamageSource.FIRE.equals(damagesource)) {
if (this.isBurning()) { if (this.isBurning()) {
@@ -428,7 +464,7 @@ @@ -428,7 +469,7 @@
} else if (damagesource.v()) { } else if (damagesource.v()) {
this.F(); this.F();
this.D(); this.D();
@ -83,7 +86,7 @@
return flag1; return flag1;
} else { } else {
long i = this.world.getTime(); long i = this.world.getTime();
@@ -439,7 +475,7 @@ @@ -439,7 +480,7 @@
} else { } else {
this.f(damagesource); this.f(damagesource);
this.D(); this.D();
@ -92,7 +95,7 @@
} }
return true; return true;
@@ -466,7 +502,7 @@ @@ -466,7 +507,7 @@
f1 -= f; f1 -= f;
if (f1 <= 0.5F) { if (f1 <= 0.5F) {
this.g(damagesource); this.g(damagesource);
@ -101,7 +104,7 @@
} else { } else {
this.setHealth(f1); this.setHealth(f1);
} }
@@ -474,13 +510,13 @@ @@ -474,13 +515,13 @@
} }
private void f(DamageSource damagesource) { private void f(DamageSource damagesource) {
@ -117,7 +120,7 @@
ItemStack itemstack; ItemStack itemstack;
int i; int i;
@@ -488,7 +524,7 @@ @@ -488,7 +529,7 @@
for (i = 0; i < this.handItems.size(); ++i) { for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i); itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@ -126,7 +129,7 @@
this.handItems.set(i, ItemStack.a); this.handItems.set(i, ItemStack.a);
} }
} }
@@ -496,10 +532,11 @@ @@ -496,10 +537,11 @@
for (i = 0; i < this.armorItems.size(); ++i) { for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i); itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
@ -139,7 +142,7 @@
} }
@@ -600,8 +637,16 @@ @@ -600,8 +642,16 @@
return this.isSmall(); return this.isSmall();
} }