Fix mobs not being able to attack players regardless of permission.

Fixes WORLDGUARD-3172.
This commit is contained in:
sk89q 2014-08-31 18:28:50 -07:00
parent 6d5d9934cc
commit 125595e6b9

View File

@ -401,12 +401,13 @@ public void onDamageEntity(DamageEntityEvent event) {
RegionAssociable associable = createRegionAssociable(event.getCause());
RegionQuery query = getPlugin().getRegionContainer().createQuery();
Object rootCause = event.getCause().getRootCause();
Player attacker;
boolean canDamage;
String what;
/* Hostile / ambient mob override */
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())) {
if (isWhitelistedEntity(event.getEntity()) || (rootCause instanceof Entity && isWhitelistedEntity((Entity) rootCause))) {
canDamage = true;
what = "hit that";
@ -465,4 +466,8 @@ public void onVehicleExit(VehicleExitEvent event) {
}
}
private boolean isWhitelistedEntity(Entity entity) {
return Entities.isHostile(entity) || Entities.isAmbient(entity);
}
}