From 7eaa84d5b15301ce9294b8dea4de846c0b80b532 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 26 Jun 2011 20:34:18 -0700 Subject: [PATCH] Added disable-ice-melting, disable-snow-formation, disable-mushroom-spread, disable-snow-melting, disable-ice-formation. --- .../worldguard/bukkit/WorldConfiguration.java | 13 ++++ .../bukkit/WorldGuardBlockListener.java | 78 ++++++++++++++++++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java index f610124a..39efadc2 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -135,6 +135,12 @@ public class WorldConfiguration { public boolean disablePigZap; public boolean disableCreeperPower; public boolean disableHealthRegain; + public boolean disableMushroomSpread; + public boolean disableIceMelting; + public boolean disableSnowMelting; + public boolean disableSnowFormation; + public boolean disableIceFormation; + public boolean disableLeafDecay; /* Configuration data end */ @@ -281,6 +287,13 @@ private void loadConfiguration() { alwaysRaining = getBoolean("weather.always-raining", false); alwaysThundering = getBoolean("weather.always-thundering", false); + disableMushroomSpread = getBoolean("dynamics.disable-mushroom-spread", false); + disableIceMelting = getBoolean("dynamics.disable-ice-melting", false); + disableSnowMelting = getBoolean("dynamics.disable-snow-melting", false); + disableSnowFormation = getBoolean("dynamics.disable-snow-formation", false); + disableIceFormation = getBoolean("dynamics.disable-ice-formation", false); + disableLeafDecay = getBoolean("dynamics.disable-leaf-decay", false); + useRegions = getBoolean("regions.enable", true); highFreqFlags = getBoolean("regions.high-frequency-flags", false); regionWand = getInt("regions.wand", 287); diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java index cfe414ae..9dd9373d 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java @@ -83,6 +83,7 @@ public void registerEvents() { registerEvent("LEAVES_DECAY", Priority.High); registerEvent("BLOCK_FORM", Priority.High); registerEvent("BLOCK_SPREAD", Priority.High); + registerEvent("BLOCK_FADE", Priority.High); } /** @@ -652,15 +653,23 @@ public void onSnowForm(SnowFormEvent event) { } ConfigurationManager cfg = plugin.getGlobalStateManager(); + WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } - if (!plugin.getGlobalRegionManager().allows(DefaultFlag.SNOW_FALL, - event.getBlock().getLocation())) { + if (wcfg.disableSnowFormation) { event.setCancelled(true); + return; + } + + if (wcfg.useRegions) { + if (!plugin.getGlobalRegionManager().allows(DefaultFlag.SNOW_FALL, + event.getBlock().getLocation())) { + event.setCancelled(true); + } } } @@ -671,14 +680,23 @@ public void onLeavesDecay(LeavesDecayEvent event) { } ConfigurationManager cfg = plugin.getGlobalStateManager(); + WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } - if (!plugin.getGlobalRegionManager().allows(DefaultFlag.LEAF_DECAY, event.getBlock().getLocation())) { + if (wcfg.disableLeafDecay) { event.setCancelled(true); + return; + } + + if (wcfg.useRegions) { + if (!plugin.getGlobalRegionManager().allows(DefaultFlag.LEAF_DECAY, + event.getBlock().getLocation())) { + event.setCancelled(true); + } } } @@ -686,23 +704,77 @@ public void onLeavesDecay(LeavesDecayEvent event) { * Called when a block is formed based on world conditions. */ public void onBlockForm(BlockFormEvent event) { + if (event.isCancelled()) { + return; + } + ConfigurationManager cfg = plugin.getGlobalStateManager(); + WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } + + Material type = event.getNewState().getType(); + + if (wcfg.disableIceFormation && type == Material.ICE) { + event.setCancelled(true); + return; + } + + if (wcfg.disableSnowFormation && type == Material.SNOW) { + event.setCancelled(true); + return; + } } /** * Called when a block spreads based on world conditions. */ public void onBlockSpread(BlockSpreadEvent event) { + if (event.isCancelled()) { + return; + } + ConfigurationManager cfg = plugin.getGlobalStateManager(); + WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } + + Material fromType = event.getSource().getType(); + + if (wcfg.disableMushroomSpread && (fromType == Material.RED_MUSHROOM + || fromType == Material.BROWN_MUSHROOM)) { + event.setCancelled(true); + return; + } + } + + /** + * Called when a block fades. + */ + public void onBlockFade(BlockFadeEvent event) { + if (event.isCancelled()) { + return; + } + + ConfigurationManager cfg = plugin.getGlobalStateManager(); + WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); + + Material type = event.getBlock().getType(); + + if (wcfg.disableIceMelting && type == Material.ICE) { + event.setCancelled(true); + return; + } + + if (wcfg.disableSnowMelting && type == Material.SNOW) { + event.setCancelled(true); + return; + } } }