Ignore entity damage caused by suffocation.

This can only occur when an entity is stuck in a wall so it should
always be allowed to happen.
This commit is contained in:
bloodshot 2020-01-15 15:54:53 -05:00
parent cb69fab753
commit 8f4d761c76

View File

@ -68,6 +68,7 @@
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.cause.EventContext;
import org.spongepowered.api.event.cause.EventContextKeys;
import org.spongepowered.api.event.cause.entity.damage.DamageTypes;
import org.spongepowered.api.event.cause.entity.damage.source.DamageSource;
import org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource;
import org.spongepowered.api.event.cause.entity.damage.source.IndirectEntityDamageSource;
@ -417,6 +418,10 @@ public void onEntityDamage(DamageEntityEvent event, @First DamageSource damageSo
}
public boolean protectEntity(Event event, Entity targetEntity, Cause cause, DamageSource damageSource) {
if (damageSource.getType() == DamageTypes.SUFFOCATE) {
// Ignore as this can only happen if an entity is stuck in wall
return false;
}
if (!GDFlags.ENTITY_DAMAGE || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(targetEntity.getWorld().getUniqueId())) {
return false;
}