Change vehicle hook changes.

By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-03 17:26:34 +08:00
parent 2ff558c10b
commit 04c824307a
6 changed files with 44 additions and 32 deletions

View file

@ -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

View file

@ -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);
}
}

View file

@ -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() {

View file

@ -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) {
}
/**

View file

@ -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;
}
}

View file

@ -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);