From 04c824307afb59e855cf660d4a40125c4e7c6e05 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 3 Jan 2011 17:26:34 +0800 Subject: [PATCH] Change vehicle hook changes. By: sk89q --- .../src/main/java/org/bukkit/event/Event.java | 2 +- .../event/vehicle/VehicleCreateEvent.java | 15 +++++++++++ .../event/vehicle/VehicleDamageEvent.java | 24 ++++++++++++++++- .../bukkit/event/vehicle/VehicleListener.java | 5 ++-- .../event/vehicle/VehiclePlaceEvent.java | 26 ------------------- .../bukkit/plugin/java/JavaPluginLoader.java | 4 +-- 6 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java delete mode 100644 paper-api/src/main/java/org/bukkit/event/vehicle/VehiclePlaceEvent.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 51992ad361..812e007df3 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -337,7 +337,7 @@ public abstract class Event { /** * Called when a vehicle is placed by a player */ - VEHICLE_PLACE (Category.VEHICLE), + VEHICLE_CREATE (Category.VEHICLE), /** * Called when a vehicle is damaged by a LivingEntity diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java new file mode 100644 index 0000000000..efc7609447 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java @@ -0,0 +1,15 @@ +package org.bukkit.event.vehicle; + +import org.bukkit.Vehicle; + +/** + * Raised when a vehicle is created. + * + * @author sk89q + */ +public class VehicleCreateEvent extends VehicleEvent { + public VehicleCreateEvent(Type type, Vehicle vehicle) { + super(type, vehicle); + } + +} diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java index fd112bd6ce..3d762e8cf0 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.vehicle; +import org.bukkit.Entity; import org.bukkit.Vehicle; import org.bukkit.event.Cancellable; @@ -9,10 +10,31 @@ import org.bukkit.event.Cancellable; * @author sk89q */ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { + private Entity attacker; + private int damage; private boolean cancelled; - public VehicleDamageEvent(Type type, Vehicle vehicle) { + public VehicleDamageEvent(Type type, Vehicle vehicle, Entity attacker, int damage) { super(type, vehicle); + this.attacker = attacker; + this.damage = damage; + } + + public Entity getAttacker() { + return attacker; + } + + public int getDamage() { + return damage; + } + + /** + * Change the damage. + * + * @param damage + */ + public void setDamage(int damage) { + this.damage = damage; } public boolean isCancelled() { 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 95e6e2df49..a285f681ec 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 @@ -7,11 +7,12 @@ package org.bukkit.event.vehicle; */ public class VehicleListener { /** - * Called when a vehicle is placed by a player. + * Called when a vehicle is created by a player. This hook will be called + * for all vehicles created. * * @param event */ - public void onVehiclePlace(VehiclePlaceEvent event) { + public void onVehicleCreate(VehicleCreateEvent event) { } /** diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehiclePlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehiclePlaceEvent.java deleted file mode 100644 index 446288790c..0000000000 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehiclePlaceEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.bukkit.event.vehicle; - -import org.bukkit.Vehicle; -import org.bukkit.event.Cancellable; - -/** - * Raised when a vehicle is placed by a player. - * - * @author sk89q - */ -public class VehiclePlaceEvent extends VehicleEvent implements Cancellable { - private boolean cancelled; - - public VehiclePlaceEvent(Type type, Vehicle vehicle) { - super(type, vehicle); - } - - public boolean isCancelled() { - return cancelled; - } - - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - -} 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 56fcbe7984..436476169c 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 @@ -137,8 +137,8 @@ public final class JavaPluginLoader implements PluginLoader { VehicleListener trueListener = (VehicleListener)listener; switch (event.getType()) { - case VEHICLE_PLACE: - trueListener.onVehiclePlace((VehiclePlaceEvent)event); + case VEHICLE_CREATE: + trueListener.onVehicleCreate((VehicleCreateEvent)event); break; case VEHICLE_DAMAGE: trueListener.onVehicleDamage((VehicleDamageEvent)event);