diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java index 7dae6009..b12c85fe 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -130,6 +130,7 @@ public class WorldConfiguration { public boolean disableMobDamage; public boolean useRegions; public boolean highFreqFlags; + public boolean checkLiquidFlow; public int regionWand; public Set blockCreatureSpawn; public boolean allowTamedSpawns; @@ -415,6 +416,7 @@ private void loadConfiguration() { regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false); explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true); highFreqFlags = getBoolean("regions.high-frequency-flags", false); + checkLiquidFlow = getBoolean("regions.protect-against-liquid-flow", false); regionWand = getInt("regions.wand", 334); maxClaimVolume = getInt("regions.max-claim-volume", 30000); claimOnlyInsideExistingRegions = getBoolean("regions.claim-only-inside-existing-regions", false); diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 0b770578..bd83a2c2 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -20,6 +20,7 @@ package com.sk89q.worldguard.bukkit.listener; import com.google.common.collect.Lists; +import com.sk89q.worldguard.bukkit.WorldConfiguration; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.cause.Cause; import com.sk89q.worldguard.bukkit.event.block.BreakBlockEvent; @@ -51,7 +52,6 @@ import org.bukkit.event.Event; import org.bukkit.event.Event.Result; import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; @@ -108,7 +108,7 @@ import static com.sk89q.worldguard.bukkit.util.Materials.isBlockModifiedOnClick; import static com.sk89q.worldguard.bukkit.util.Materials.isItemAppliedToBlock; -public class EventAbstractionListener implements Listener { +public class EventAbstractionListener extends AbstractListener { /** * Abstract {@link BlockFromToEvent}s into break and place events. @@ -116,14 +116,17 @@ public class EventAbstractionListener implements Listener { */ public static final boolean ABSTRACT_FROM_TO_EVENTS = false; - private final WorldGuardPlugin plugin; - + /** + * Construct the listener. + * + * @param plugin an instance of WorldGuardPlugin + */ public EventAbstractionListener(WorldGuardPlugin plugin) { - this.plugin = plugin; + super(plugin); } public void registerEvents() { - plugin.getServer().getPluginManager().registerEvents(this, plugin); + getPlugin().getServer().getPluginManager().registerEvents(this, getPlugin()); } //------------------------------------------------------------------------- @@ -382,6 +385,14 @@ public void onPlayerBucketFill(PlayerBucketFillEvent event) { @EventHandler public void onBlockFromTo(BlockFromToEvent event) { + WorldConfiguration config = getWorldConfig(event.getBlock().getWorld()); + + // This only applies to regions but nothing else cares about high + // frequency events at the moment + if (!config.useRegions || (!config.highFreqFlags && !config.checkLiquidFlow)) { + return; + } + Block from = event.getBlock(); Block to = event.getToBlock(); Material fromType = from.getType(); diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java index 26d5276d..da434415 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java @@ -113,6 +113,11 @@ public void onPlaceBlock(final PlaceBlockEvent event) { final RegionQuery query = getPlugin().getRegionContainer().createQuery(); final RegionAssociable associable = createRegionAssociable(event.getCause()); + // Don't check liquid flow unless it's enabled + if (Materials.isLiquid(type) && !getWorldConfig(event.getWorld()).checkLiquidFlow) { + return; + } + event.filter(new Predicate() { @Override public boolean apply(Location target) {