From e98a0532b6109b5eddb7242f1e18927fe3598c38 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Wed, 16 Sep 2015 14:41:05 -0700 Subject: [PATCH] More wilderness protections for creative mode. Blocks don't form outside of claims, fluids don't flow outside of claims. --- .../GriefPrevention/BlockEventHandler.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java index 6d53e1f..c45549d 100644 --- a/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/BlockEventHandler.java @@ -39,6 +39,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; @@ -669,6 +670,32 @@ public class BlockEventHandler implements Listener } } } + + //otherwise if creative mode world, don't flow + else if(GriefPrevention.instance.creativeRulesApply(toLocation)) + { + spreadEvent.setCancelled(true); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) + public void onForm(BlockFormEvent event) + { + Block block = event.getBlock(); + Location location = block.getLocation(); + + if(GriefPrevention.instance.creativeRulesApply(location)) + { + Material type = block.getType(); + if(type == Material.COBBLESTONE || type == Material.OBSIDIAN || type == Material.STATIONARY_LAVA || type == Material.STATIONARY_WATER) + { + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null); + if(claim == null) + { + event.setCancelled(true); + } + } + } } //ensures dispensers can't be used to dispense a block(like water or lava) or item across a claim boundary