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 grows naturally in the world.
010     * <p>
011     * Examples:
012     * <ul>
013     * <li>Wheat
014     * <li>Sugar Cane
015     * <li>Cactus
016     * <li>Watermelon
017     * <li>Pumpkin
018     * </ul>
019     * <p>
020     * If a Block Grow event is cancelled, the block will not grow.
021     */
022    public class BlockGrowEvent extends BlockEvent implements Cancellable {
023        private static final HandlerList handlers = new HandlerList();
024        private final BlockState newState;
025        private boolean cancelled = false;
026    
027        public BlockGrowEvent(final Block block, final BlockState newState) {
028            super(block);
029            this.newState = newState;
030        }
031    
032        /**
033         * Gets the state of the block where it will form or spread to.
034         *
035         * @return The block state for this events block
036         */
037        public BlockState getNewState() {
038            return newState;
039        }
040    
041        public boolean isCancelled() {
042            return cancelled;
043        }
044    
045        public void setCancelled(boolean cancel) {
046            this.cancelled = cancel;
047        }
048    
049        public HandlerList getHandlers() {
050            return handlers;
051        }
052    
053        public static HandlerList getHandlerList() {
054            return handlers;
055        }
056    }