From 22b860367d56ea2ec97ce3158b100e0af825429d Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 16 Mar 2011 13:11:13 +0000 Subject: [PATCH] Added VEHICLE_DESTROY event By: Robert Sargant --- .../src/main/java/org/bukkit/event/Event.java | 7 ++++ .../event/vehicle/VehicleDestroyEvent.java | 33 +++++++++++++++++++ .../bukkit/event/vehicle/VehicleListener.java | 8 +++++ .../bukkit/plugin/java/JavaPluginLoader.java | 5 +++ 4 files changed, 53 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index dd59c06921..01ad2acf06 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -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 * diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java new file mode 100644 index 0000000000..195158eaf6 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java @@ -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; + } + +} diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java index 321801078a..bacde32fe9 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleListener.java @@ -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 * diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index ceb750ad7e..017076c7a2 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -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) {