Allow right clicking hostile mobs in protected regions too.

Fixes WORLDGUARD-3144.
This commit is contained in:
sk89q 2014-08-25 00:09:29 -07:00
parent 438bc59fbc
commit f776d15e03

View File

@ -372,8 +372,19 @@ public void onUseEntity(UseEntityEvent event) {
RegionAssociable associable = createRegionAssociable(event.getCause());
RegionQuery query = getPlugin().getRegionContainer().createQuery();
boolean canUse = query.testState(target, associable, DefaultFlag.BUILD) || query.testState(target, associable, DefaultFlag.USE);
String what = "use that";
boolean canUse;
String what;
/* Hostile / ambient mob override */
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())) {
canUse = true;
what = "use that";
/* Everything else */
} else {
canUse = query.testState(target, associable, DefaultFlag.BUILD) || query.testState(target, associable, DefaultFlag.USE);
what = "use that";
}
if (!canUse) {
tellErrorMessage(event, event.getCause(), target, what);