Updated snow fall and added flags for snow/ice forming/melting and mushroom growth

This commit is contained in:
Wizjany 2011-08-06 11:29:14 -04:00
parent 049a1fb2ed
commit 40a66b9be4
2 changed files with 55 additions and 49 deletions

View File

@ -44,7 +44,6 @@
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.block.SnowFormEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
@ -97,7 +96,6 @@ public void registerEvents() {
registerEvent("BLOCK_BURN", Priority.High);
registerEvent("SIGN_CHANGE", Priority.High);
registerEvent("REDSTONE_CHANGE", Priority.High);
registerEvent("SNOW_FORM", Priority.High);
registerEvent("LEAVES_DECAY", Priority.High);
registerEvent("BLOCK_FORM", Priority.High);
registerEvent("BLOCK_SPREAD", Priority.High);
@ -660,36 +658,6 @@ public void onSignChange(SignChangeEvent event) {
return;
}
}
/**
* Called when snow is formed.
*/
@Override
public void onSnowForm(SnowFormEvent event) {
if (event.isCancelled()) {
return;
}
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
if (cfg.activityHaltToggle) {
event.setCancelled(true);
return;
}
if (wcfg.disableSnowFormation) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions) {
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.SNOW_FALL,
event.getBlock().getLocation())) {
event.setCancelled(true);
}
}
}
@Override
public void onLeavesDecay(LeavesDecayEvent event) {
@ -736,14 +704,28 @@ public void onBlockForm(BlockFormEvent event) {
Material type = event.getNewState().getType();
if (wcfg.disableIceFormation && type == Material.ICE) {
event.setCancelled(true);
return;
if (type == Material.ICE) {
if (wcfg.disableIceFormation) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
DefaultFlag.ICE_FORM, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
}
if (wcfg.disableSnowFormation && type == Material.SNOW) {
event.setCancelled(true);
return;
if (type == Material.SNOW) {
if (wcfg.disableSnowFormation) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
DefaultFlag.SNOW_FALL, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
}
}
@ -765,10 +747,16 @@ public void onBlockSpread(BlockSpreadEvent event) {
Material fromType = event.getSource().getType();
if (wcfg.disableMushroomSpread && (fromType == Material.RED_MUSHROOM
|| fromType == Material.BROWN_MUSHROOM)) {
event.setCancelled(true);
return;
if (fromType == Material.RED_MUSHROOM || fromType == Material.BROWN_MUSHROOM) {
if (wcfg.disableMushroomSpread) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
DefaultFlag.MUSHROOMS, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
}
}
@ -785,14 +773,28 @@ public void onBlockFade(BlockFadeEvent event) {
Material type = event.getBlock().getType();
if (wcfg.disableIceMelting && type == Material.ICE) {
event.setCancelled(true);
return;
if (type == Material.ICE) {
if (wcfg.disableIceMelting) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
DefaultFlag.ICE_MELT, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
}
if (wcfg.disableSnowMelting && type == Material.SNOW) {
event.setCancelled(true);
return;
if (type == Material.SNOW) {
if (wcfg.disableSnowMelting) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
DefaultFlag.SNOW_MELT, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
}
}
}

View File

@ -46,6 +46,10 @@ public final class DefaultFlag {
public static final StateFlag USE = new StateFlag("use", true);
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 SNOW_MELT = new StateFlag("snow-melt", true);
public static final StateFlag ICE_FORM = new StateFlag("ice-form", true);
public static final StateFlag ICE_MELT = new StateFlag("ice-melt", true);
public static final StateFlag MUSHROOMS = new StateFlag("mushroom-growth", true);
public static final StateFlag LEAF_DECAY = new StateFlag("leaf-decay", true);
public static final StateFlag INVINCIBILITY = new StateFlag("invincible", false);
public static final StateFlag ENTRY = new StateFlag("entry", true);
@ -75,7 +79,7 @@ public final class DefaultFlag {
NOTIFY_LEAVE, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT, TELE_LOC,
TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, LEAF_DECAY,
GHAST_FIREBALL, BLOCKED_CMDS, ALLOWED_CMDS, ENTRY, ENTRY_PERM, EXIT, EXIT_PERM,
INVINCIBILITY
INVINCIBILITY, SNOW_MELT, ICE_MELT, ICE_FORM, MUSHROOMS
};
static {