Add region support check in RegionProtectionListener.

This commit is contained in:
sk89q 2014-08-18 23:31:52 -07:00
parent 53957e7b26
commit d29f66563b

View File

@ -101,9 +101,8 @@ private RegionAssociable createRegionAssociable(Cause cause) {
@EventHandler(ignoreCancelled = true)
public void onPlaceBlock(final PlaceBlockEvent event) {
if (isWhitelisted(event.getCause())) {
return; // Whitelisted cause
}
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
if (isWhitelisted(event.getCause())) return; // Whitelisted cause
final Material type = event.getEffectiveMaterial();
final RegionQuery query = getPlugin().getRegionContainer().createQuery();
@ -134,9 +133,8 @@ public boolean apply(Location target) {
@EventHandler(ignoreCancelled = true)
public void onBreakBlock(final BreakBlockEvent event) {
if (isWhitelisted(event.getCause())) {
return; // Whitelisted cause
}
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
if (isWhitelisted(event.getCause())) return; // Whitelisted cause
final RegionQuery query = getPlugin().getRegionContainer().createQuery();
@ -161,9 +159,8 @@ public boolean apply(Location target) {
@EventHandler(ignoreCancelled = true)
public void onUseBlock(final UseBlockEvent event) {
if (isWhitelisted(event.getCause())) {
return; // Whitelisted cause
}
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
if (isWhitelisted(event.getCause())) return; // Whitelisted cause
final Material type = event.getEffectiveMaterial();
final RegionQuery query = getPlugin().getRegionContainer().createQuery();
@ -203,9 +200,8 @@ public boolean apply(Location target) {
@EventHandler(ignoreCancelled = true)
public void onSpawnEntity(SpawnEntityEvent event) {
if (isWhitelisted(event.getCause())) {
return; // Whitelisted cause
}
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
if (isWhitelisted(event.getCause())) return; // Whitelisted cause
Location target = event.getTarget();
EntityType type = event.getEffectiveType();
@ -229,9 +225,8 @@ public void onSpawnEntity(SpawnEntityEvent event) {
@EventHandler(ignoreCancelled = true)
public void onDestroyEntity(DestroyEntityEvent event) {
if (isWhitelisted(event.getCause())) {
return; // Whitelisted cause
}
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
if (isWhitelisted(event.getCause())) return; // Whitelisted cause
Location target = event.getTarget();
EntityType type = event.getEntity().getType();
@ -254,9 +249,8 @@ public void onDestroyEntity(DestroyEntityEvent event) {
@EventHandler(ignoreCancelled = true)
public void onUseEntity(UseEntityEvent event) {
if (isWhitelisted(event.getCause())) {
return; // Whitelisted cause
}
if (!isRegionSupportEnabled(event.getWorld())) return; // Region support disabled
if (isWhitelisted(event.getCause())) return; // Whitelisted cause
Location target = event.getTarget();
RegionAssociable associable = createRegionAssociable(event.getCause());