diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java index da6e46fa..34029a4c 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java @@ -72,6 +72,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); } /** @@ -481,7 +482,7 @@ public void onBlockPlace(BlockPlaceEvent event) { int oy = blockPlaced.getY(); int oz = blockPlaced.getZ(); - clearSpongeWater(plugin, world, ox, oy, oz); + SpongeUtil.clearSpongeWater(plugin, world, ox, oy, oz); } } @@ -508,10 +509,10 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) { Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz); if (sponge.getTypeId() == 19 && sponge.isBlockIndirectlyPowered()) { - clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); + SpongeUtil.clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); } else if (sponge.getTypeId() == 19 && !sponge.isBlockIndirectlyPowered()) { - addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); + SpongeUtil.addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); } } } @@ -599,4 +600,49 @@ 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. + * + * @param block + */ + private void dropSign(Block block) { + block.setTypeId(0); + block.getWorld().dropItemNaturally(block.getLocation(), + new ItemStack(Material.SIGN, 1)); + } + + /** + * Remove water around a sponge. + * + * @param world + * @param ox + * @param oy + * @param oz + */ + private void clearSpongeWater(World world, int ox, int oy, int oz) { + + ConfigurationManager cfg = plugin.getGlobalConfiguration(); + WorldConfiguration wcfg = cfg.get(world); + + for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) { + for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) { + for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) { + if (isBlockWater(world, ox + cx, oy + cy, oz + cz)) { + world.getBlockAt(ox + cx, oy + cy, oz + cz).setTypeId(0); + } + } + } + } + } } diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java index f892cb64..92e7e806 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java @@ -260,6 +260,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) { if (type == Material.STONE_BUTTON || type == Material.LEVER || type == Material.WOODEN_DOOR + || type == Material.TRAP_DOOR || type == Material.NOTE_BLOCK) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.USE) @@ -383,6 +384,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) { || type == Material.DIODE_BLOCK_OFF || type == Material.DIODE_BLOCK_ON || type == Material.WOODEN_DOOR + || type == Material.TRAP_DOOR || type == Material.WORKBENCH) { if (!plugin.getGlobalRegionManager().hasBypass(player, world) && !set.allows(DefaultFlag.USE) 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 7ea2d76c..1d23f5f5 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_ENTER = new BooleanFlag("notify-enter"); @@ -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_ENTER, NOTIFY_LEAVE, 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 };