001 package org.bukkit.event.block;
002
003 import org.bukkit.block.Block;
004 import org.bukkit.block.BlockState;
005 import org.bukkit.event.Cancellable;
006 import org.bukkit.event.HandlerList;
007
008 /**
009 * Called when a block fades, melts or disappears based on world conditions
010 * <p>
011 * Examples:
012 * <ul>
013 * <li>Snow melting due to being near a light source.
014 * <li>Ice melting due to being near a light source.
015 * <li>Fire burning out after time, without destroying fuel block.
016 * </ul>
017 * <p>
018 * If a Block Fade event is cancelled, the block will not fade, melt or
019 * disappear.
020 */
021 public class BlockFadeEvent extends BlockEvent implements Cancellable {
022 private static final HandlerList handlers = new HandlerList();
023 private boolean cancelled;
024 private final BlockState newState;
025
026 public BlockFadeEvent(final Block block, final BlockState newState) {
027 super(block);
028 this.newState = newState;
029 this.cancelled = false;
030 }
031
032 /**
033 * Gets the state of the block that will be fading, melting or
034 * disappearing.
035 *
036 * @return The block state of the block that will be fading, melting or
037 * disappearing
038 */
039 public BlockState getNewState() {
040 return newState;
041 }
042
043 public boolean isCancelled() {
044 return cancelled;
045 }
046
047 public void setCancelled(boolean cancel) {
048 this.cancelled = cancel;
049 }
050
051 @Override
052 public HandlerList getHandlers() {
053 return handlers;
054 }
055
056 public static HandlerList getHandlerList() {
057 return handlers;
058 }
059 }