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 * 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 * 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; package org.bukkit.event.vehicle;
import org.bukkit.Entity;
import org.bukkit.Vehicle; import org.bukkit.Vehicle;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
@ -9,10 +10,31 @@ import org.bukkit.event.Cancellable;
* @author sk89q * @author sk89q
*/ */
public class VehicleDamageEvent extends VehicleEvent implements Cancellable { public class VehicleDamageEvent extends VehicleEvent implements Cancellable {
private Entity attacker;
private int damage;
private boolean cancelled; private boolean cancelled;
public VehicleDamageEvent(Type type, Vehicle vehicle) { public VehicleDamageEvent(Type type, Vehicle vehicle, Entity attacker, int damage) {
super(type, vehicle); 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() { public boolean isCancelled() {

View File

@ -7,11 +7,12 @@ package org.bukkit.event.vehicle;
*/ */
public class VehicleListener { 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 * @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; VehicleListener trueListener = (VehicleListener)listener;
switch (event.getType()) { switch (event.getType()) {
case VEHICLE_PLACE: case VEHICLE_CREATE:
trueListener.onVehiclePlace((VehiclePlaceEvent)event); trueListener.onVehicleCreate((VehicleCreateEvent)event);
break; break;
case VEHICLE_DAMAGE: case VEHICLE_DAMAGE:
trueListener.onVehicleDamage((VehicleDamageEvent)event); trueListener.onVehicleDamage((VehicleDamageEvent)event);