Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockIgniteEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.block.Block;
4 import org.bukkit.entity.Entity;
5 import org.bukkit.entity.Player;
8 
9 /**
10  * Called when a block is ignited. If you want to catch when a Player places
11  * fire, you need to use {@link BlockPlaceEvent}.
12  * <p>
13  * If a Block Ignite event is cancelled, the block will not be ignited.
14  */
15 public class BlockIgniteEvent extends BlockEvent implements Cancellable {
16  private static final HandlerList handlers = new HandlerList();
17  private final IgniteCause cause;
18  private final Entity ignitingEntity;
19  private final Block ignitingBlock;
20  private boolean cancel;
21 
22  /**
23  * @deprecated use {@link BlockIgniteEvent#BlockIgniteEvent(Block,
24  * IgniteCause, Entity)} instead.
25  */
26  @Deprecated
27  public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Player thePlayer) {
28  this(theBlock, cause, (Entity) thePlayer);
29  }
30 
31  public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity) {
32  this(theBlock, cause, ignitingEntity, null);
33  }
34 
35  public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Block ignitingBlock) {
36  this(theBlock, cause, null, ignitingBlock);
37  }
38 
39  public BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Entity ignitingEntity, final Block ignitingBlock) {
40  super(theBlock);
41  this.cause = cause;
42  this.ignitingEntity = ignitingEntity;
43  this.ignitingBlock = ignitingBlock;
44  this.cancel = false;
45  }
46 
47  public boolean isCancelled() {
48  return cancel;
49  }
50 
51  public void setCancelled(boolean cancel) {
52  this.cancel = cancel;
53  }
54 
55  /**
56  * Gets the cause of block ignite.
57  *
58  * @return An IgniteCause value detailing the cause of block ignition
59  */
60  public IgniteCause getCause() {
61  return cause;
62  }
63 
64  /**
65  * Gets the player who ignited this block
66  *
67  * @return The Player that placed/ignited the fire block, or null if not ignited by a Player.
68  */
69  public Player getPlayer() {
70  if (ignitingEntity instanceof Player) {
71  return (Player) ignitingEntity;
72  }
73 
74  return null;
75  }
76 
77  /**
78  * Gets the entity who ignited this block
79  *
80  * @return The Entity that placed/ignited the fire block, or null if not ignited by a Entity.
81  */
83  return ignitingEntity;
84  }
85 
86  /**
87  * Gets the block who ignited this block
88  *
89  * @return The Block that placed/ignited the fire block, or null if not ignited by a Block.
90  */
92  return ignitingBlock;
93  }
94 
95  /**
96  * An enum to specify the cause of the ignite
97  */
98  public enum IgniteCause {
99 
100  /**
101  * Block ignition caused by lava.
102  */
104  /**
105  * Block ignition caused by a player or dispenser using flint-and-steel.
106  */
108  /**
109  * Block ignition caused by dynamic spreading of fire.
110  */
112  /**
113  * Block ignition caused by lightning.
114  */
116  /**
117  * Block ignition caused by an entity using a fireball.
118  */
120  /**
121  * Block ignition caused by an Ender Crystal.
122  */
124  /**
125  * Block ignition caused by explosion.
126  */
128  }
129 
130  @Override
131  public HandlerList getHandlers() {
132  return handlers;
133  }
134 
135  public static HandlerList getHandlerList() {
136  return handlers;
137  }
138 }
BlockIgniteEvent(final Block theBlock, final IgniteCause cause, final Player thePlayer)