Various changes to the vehicle hooks.

By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
Bukkit/Spigot 2011-01-07 11:16:04 -08:00
parent 7f70bc53b8
commit f0cb8573a9
4 changed files with 73 additions and 11 deletions

View file

@ -24,9 +24,9 @@ public interface Vehicle extends Entity {
* Gets the primary passenger of a vehicle. For vehicles that could have * Gets the primary passenger of a vehicle. For vehicles that could have
* multiple passengers, this will only return the primary passenger. * multiple passengers, this will only return the primary passenger.
* *
* @return a living entity * @return an entity
*/ */
public LivingEntity getPassenger(); public Entity getPassenger();
/** /**
* Returns true if the vehicle has no passengers. * Returns true if the vehicle has no passengers.

View file

@ -1,5 +1,6 @@
package org.bukkit.event.vehicle; package org.bukkit.event.vehicle;
import org.bukkit.Vector;
import org.bukkit.Vehicle; import org.bukkit.Vehicle;
/** /**
@ -8,8 +9,41 @@ import org.bukkit.Vehicle;
* @author sk89q * @author sk89q
*/ */
public class VehicleCreateEvent extends VehicleEvent { public class VehicleCreateEvent extends VehicleEvent {
public VehicleCreateEvent(Type type, Vehicle vehicle) { private boolean slowWhenEmpty;
private Vector derailedVelocityFactor;
private Vector flyingVelocityFactor;
public VehicleCreateEvent(Type type, Vehicle vehicle,
boolean slowWhenEmpty, Vector derailedVelocityFactor,
Vector flyingVelocityFactor) {
super(type, vehicle); super(type, vehicle);
this.slowWhenEmpty = slowWhenEmpty;
this.derailedVelocityFactor = derailedVelocityFactor;
this.flyingVelocityFactor = flyingVelocityFactor;
}
public void setSlowWhenEmpty(boolean setting) {
slowWhenEmpty = setting;
}
public boolean shouldSlowWhenEmpty() {
return slowWhenEmpty;
}
public void setDerailedVelocityFactor(Vector setting) {
derailedVelocityFactor = setting.clone();
}
public Vector getDerailedVelocityFactor() {
return derailedVelocityFactor.clone();
}
public void setFlyingVelocityFactor(Vector setting) {
flyingVelocityFactor = setting.clone();
}
public Vector getFlyingVelocityFactor() {
return flyingVelocityFactor.clone();
} }
} }

View file

@ -1,30 +1,30 @@
package org.bukkit.event.vehicle; package org.bukkit.event.vehicle;
import org.bukkit.LivingEntity; import org.bukkit.Entity;
import org.bukkit.Vehicle; import org.bukkit.Vehicle;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
/** /**
* Raised when a living entity enters a vehicle. * Raised when an entity enters a vehicle.
* *
* @author sk89q * @author sk89q
*/ */
public class VehicleEnterEvent extends VehicleEvent implements Cancellable { public class VehicleEnterEvent extends VehicleEvent implements Cancellable {
private boolean cancelled; private boolean cancelled;
private LivingEntity entered; private Entity entered;
public VehicleEnterEvent(Type type, Vehicle vehicle, LivingEntity entered) { public VehicleEnterEvent(Type type, Vehicle vehicle, Entity entered) {
super(type, vehicle); super(type, vehicle);
this.entered = entered; this.entered = entered;
} }
/** /**
* Get the living entity that entered the vehicle. * Get the entity that entered the vehicle.
* *
* @return * @return
*/ */
public LivingEntity getEntered() { public Entity getEntered() {
return entered; return entered;
} }

View file

@ -2,14 +2,18 @@ package org.bukkit.event.vehicle;
import org.bukkit.Entity; import org.bukkit.Entity;
import org.bukkit.Vehicle; import org.bukkit.Vehicle;
import org.bukkit.event.Cancellable;
/** /**
* Raised when a vehicle collides with an entity. * Raised when a vehicle collides with an entity.
* *
* @author sk89q * @author sk89q
*/ */
public class VehicleEntityCollisionEvent extends VehicleCollisionEvent { public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implements Cancellable {
private Entity entity; private Entity entity;
private boolean cancelled = false;
private boolean cancelledPickup = false;
private boolean cancelledCollision = false;
public VehicleEntityCollisionEvent(Type type, Vehicle vehicle, Entity entity) { public VehicleEntityCollisionEvent(Type type, Vehicle vehicle, Entity entity) {
super(type, vehicle); super(type, vehicle);
@ -19,4 +23,28 @@ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent {
public Entity getEntity() { public Entity getEntity() {
return entity; return entity;
} }
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
public boolean isPickupCancelled() {
return cancelledPickup;
}
public void setPickupCancelled(boolean cancel) {
cancelledPickup = cancel;
}
public boolean isCollisionCancelled() {
return cancelledCollision;
}
public void setCollisionCancelled(boolean cancel) {
cancelledCollision = cancel;
}
} }