Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
CreeperPowerEvent.java
1 package org.bukkit.event.entity;
2 
3 import org.bukkit.entity.Creeper;
7 
8 /**
9  * Called when a Creeper is struck by lightning.
10  * <p>
11  * If a Creeper Power event is cancelled, the Creeper will not be powered.
12  */
13 public class CreeperPowerEvent extends EntityEvent implements Cancellable {
14  private static final HandlerList handlers = new HandlerList();
15  private boolean canceled;
16  private final PowerCause cause;
17  private LightningStrike bolt;
18 
19  public CreeperPowerEvent(final Creeper creeper, final LightningStrike bolt, final PowerCause cause) {
20  this(creeper, cause);
21  this.bolt = bolt;
22  }
23 
24  public CreeperPowerEvent(final Creeper creeper, final PowerCause cause) {
25  super(creeper);
26  this.cause = cause;
27  }
28 
29  public boolean isCancelled() {
30  return canceled;
31  }
32 
33  public void setCancelled(boolean cancel) {
34  canceled = cancel;
35  }
36 
37  @Override
38  public Creeper getEntity() {
39  return (Creeper) entity;
40  }
41 
42  /**
43  * Gets the lightning bolt which is striking the Creeper.
44  *
45  * @return The Entity for the lightning bolt which is striking the Creeper
46  */
48  return bolt;
49  }
50 
51  /**
52  * Gets the cause of the creeper being (un)powered.
53  *
54  * @return A PowerCause value detailing the cause of change in power.
55  */
56  public PowerCause getCause() {
57  return cause;
58  }
59 
60  @Override
61  public HandlerList getHandlers() {
62  return handlers;
63  }
64 
65  public static HandlerList getHandlerList() {
66  return handlers;
67  }
68 
69  /**
70  * An enum to specify the cause of the change in power
71  */
72  public enum PowerCause {
73 
74  /**
75  * Power change caused by a lightning bolt
76  * <p>
77  * Powered state: true
78  */
80  /**
81  * Power change caused by something else (probably a plugin)
82  * <p>
83  * Powered state: true
84  */
86  /**
87  * Power change caused by something else (probably a plugin)
88  * <p>
89  * Powered state: false
90  */
91  SET_OFF
92  }
93 }