Added VEHICLE_DESTROY event

By: Robert Sargant <robert@sargant.com>
This commit is contained in:
Bukkit/Spigot 2011-03-16 13:11:13 +00:00
parent 531a69463a
commit 22b860367d
4 changed files with 53 additions and 0 deletions

View File

@ -544,6 +544,13 @@ public abstract class Event implements Serializable {
*/
VEHICLE_CREATE (Category.VEHICLE),
/**
* Called when a vehicle is destroyed
*
* @see org.bukkit.event.vehicle.VehicleDestroyEvent
*/
VEHICLE_DESTROY (Category.VEHICLE),
/**
* Called when a vehicle is damaged by a LivingEntity
*

View File

@ -0,0 +1,33 @@
package org.bukkit.event.vehicle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.Cancellable;
/**
* Raised when a vehicle is destroyed
*
* @author sk89q, cyklo
*/
public class VehicleDestroyEvent extends VehicleEvent implements Cancellable {
private Entity attacker;
private boolean cancelled;
public VehicleDestroyEvent(Vehicle vehicle, Entity attacker) {
super(Type.VEHICLE_DESTROY, vehicle);
this.attacker = attacker;
}
public Entity getAttacker() {
return attacker;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}

View File

@ -69,6 +69,14 @@ public class VehicleListener implements Listener {
public void onVehicleMove(VehicleMoveEvent event) {
}
/**
* Called when a vehicle is destroyed.
*
* @param event
*/
public void onVehicleDestroy(VehicleDestroyEvent event) {
}
/**
* Called when a vehicle goes through an update cycle
*

View File

@ -455,6 +455,11 @@ public final class JavaPluginLoader implements PluginLoader {
((VehicleListener) listener).onVehicleDamage((VehicleDamageEvent) event);
}
};
case VEHICLE_DESTROY:
return new EventExecutor() { public void execute( Listener listener, Event event ) {
((VehicleListener)listener).onVehicleDestroy( (VehicleDestroyEvent)event );
}
};
case VEHICLE_COLLISION_BLOCK:
return new EventExecutor() {
public void execute(Listener listener, Event event) {