Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
VehicleDamageEvent.java
1 package org.bukkit.event.vehicle;
2 
3 import org.bukkit.entity.Entity;
4 import org.bukkit.entity.Vehicle;
8 
9 /**
10  * Raised when a vehicle receives damage.
11  */
12 public class VehicleDamageEvent extends VehicleEvent implements Cancellable {
13  private static final HandlerList handlers = new HandlerList();
14  private final Entity attacker;
15  private double damage;
16  private boolean cancelled;
17 
18  @Deprecated
19  public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final int damage) {
20  this(vehicle, attacker, (double) damage);
21  }
22 
23  public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final double damage) {
24  super(vehicle);
25  this.attacker = attacker;
26  this.damage = damage;
27  }
28 
29  /**
30  * Gets the Entity that is attacking the vehicle
31  *
32  * @return the Entity that is attacking the vehicle
33  */
34  public Entity getAttacker() {
35  return attacker;
36  }
37 
38  /**
39  * Gets the damage done to the vehicle
40  *
41  * @return the damage done to the vehicle
42  */
43  public double getDamage() {
44  return damage;
45  }
46 
47  /**
48  * This method exists for legacy reasons to provide backwards
49  * compatibility. It will not exist at runtime and should not be used
50  * under any circumstances.
51  */
52  @Deprecated
53  public int _INVALID_getDamage() {
54  return NumberConversions.ceil(getDamage());
55  }
56 
57  /**
58  * Sets the damage done to the vehicle
59  *
60  * @param damage The damage
61  */
62  public void setDamage(double damage) {
63  this.damage = damage;
64  }
65 
66  /**
67  * This method exists for legacy reasons to provide backwards
68  * compatibility. It will not exist at runtime and should not be used
69  * under any circumstances.
70  */
71  @Deprecated
72  public void _INVALID_setDamage(int damage) {
73  setDamage(damage);
74  }
75 
76  public boolean isCancelled() {
77  return cancelled;
78  }
79 
80  public void setCancelled(boolean cancel) {
81  this.cancelled = cancel;
82  }
83 
84  @Override
85  public HandlerList getHandlers() {
86  return handlers;
87  }
88 
89  public static HandlerList getHandlerList() {
90  return handlers;
91  }
92 }