From 26946feecc437b645fb1df47bcd494369b83b45d Mon Sep 17 00:00:00 2001 From: Wizjany Date: Fri, 27 May 2011 19:05:27 -0400 Subject: [PATCH] Merge leafdecay flag from zml2008 --- .../worldguard/bukkit/WorldGuardBlockListener.java | 12 ++++++++++++ .../worldguard/protection/flags/DefaultFlag.java | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java index f9aaa6a4..050f876f 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java @@ -67,6 +67,7 @@ public void registerEvents() { pm.registerEvent(Event.Type.SIGN_CHANGE, this, Priority.High, plugin); pm.registerEvent(Event.Type.REDSTONE_CHANGE, this, Priority.High, plugin); pm.registerEvent(Event.Type.SNOW_FORM, this, Priority.High, plugin); + pm.registerEvent(Event.Type.LEAVES_DECAY, this, Priority.High, plugin); } protected WorldConfiguration getWorldConfig(World world) { @@ -554,6 +555,17 @@ public void onSnowForm(SnowFormEvent event) { event.setCancelled(true); } } + + @Override + public void onLeavesDecay(LeavesDecayEvent event) { + if (event.isCancelled()) { + return; + } + + if (!plugin.getGlobalRegionManager().allows(DefaultFlag.LEAF_DECAY, event.getBlock().getLocation())) { + event.setCancelled(true); + } + } /** * Drops a sign item and removes a sign. * diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java index 494f5ca2..54d4c683 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java @@ -44,6 +44,7 @@ public final class DefaultFlag { public static final StateFlag USE = new StateFlag("use", false); public static final StateFlag PLACE_VEHICLE = new StateFlag("vehicle-place", false); public static final StateFlag SNOW_FALL = new StateFlag("snow-fall", true); + public static final StateFlag LEAF_DECAY = new StateFlag("leaf-decay", true); public static final StringFlag GREET_MESSAGE = new StringFlag("greeting"); public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell"); public static final BooleanFlag NOTIFY_GREET = new BooleanFlag("notify-greet"); @@ -63,7 +64,7 @@ public final class DefaultFlag { TNT, LIGHTER, FIRE_SPREAD, LAVA_FIRE, CHEST_ACCESS, WATER_FLOW, LAVA_FLOW, USE, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_GREET, NOTIFY_FAREWELL, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT, TELE_LOC, - TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, + TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, LEAF_DECAY, GHAST_FIREBALL };