Added disable-ice-melting, disable-snow-formation, disable-mushroom-spread, disable-snow-melting, disable-ice-formation.

This commit is contained in:
sk89q 2011-06-26 20:34:18 -07:00
parent ad325dfedb
commit 7eaa84d5b1
2 changed files with 88 additions and 3 deletions

View File

@ -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);

View File

@ -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;
}
}
}