All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bukkit.event.vehicle.VehicleDamageEvent Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package org.bukkit.event.vehicle;

import org.bukkit.entity.Entity;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.util.NumberConversions;

/**
 * Raised when a vehicle receives damage.
 */
public class VehicleDamageEvent extends VehicleEvent implements Cancellable {
  private static final HandlerList handlers = new HandlerList();
  private final Entity attacker;
  private double damage;
  private boolean cancelled;

  @Deprecated
  public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final int damage) {
    this(vehicle, attacker, (double) damage);
  }

  public VehicleDamageEvent(final Vehicle vehicle, final Entity attacker, final double damage) {
    super(vehicle);
    this.attacker = attacker;
    this.damage = damage;
  }

  public static HandlerList getHandlerList() {
    return handlers;
  }

  /**
   * Gets the Entity that is attacking the vehicle
   *
   * @return the Entity that is attacking the vehicle
   */
  public Entity getAttacker() {
    return attacker;
  }

  /**
   * Gets the damage done to the vehicle
   *
   * @return the damage done to the vehicle
   */
  public double getDamage() {
    return damage;
  }

  /**
   * Sets the damage done to the vehicle
   *
   * @param damage The damage
   */
  public void setDamage(double damage) {
    this.damage = damage;
  }

  /**
   * This method exists for legacy reasons to provide backwards
   * compatibility. It will not exist at runtime and should not be used
   * under any circumstances.
   *
   * @return the damage
   */
  @Deprecated
  public int _INVALID_getDamage() {
    return NumberConversions.ceil(getDamage());
  }

  /**
   * This method exists for legacy reasons to provide backwards
   * compatibility. It will not exist at runtime and should not be used
   * under any circumstances.
   *
   * @param damage the damage
   */
  @Deprecated
  public void _INVALID_setDamage(int damage) {
    setDamage(damage);
  }

  public boolean isCancelled() {
    return cancelled;
  }

  public void setCancelled(boolean cancel) {
    this.cancelled = cancel;
  }

  @Override
  public HandlerList getHandlers() {
    return handlers;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy