use of org.spigotmc.event.entity.EntityDismountEvent in project Glowstone by GlowstoneMC.
the class GlowEntity method removePassenger.
@Override
public boolean removePassenger(Entity passenger) {
Preconditions.checkArgument(!this.equals(passenger), "Entity cannot ride itself.");
if (passenger == null || !passengers.contains(passenger)) {
// nothing changed
return false;
}
if (EventFactory.getInstance().callEvent(new EntityDismountEvent(passenger, this)).isCancelled()) {
return false;
}
if (!(passenger instanceof GlowEntity)) {
return false;
}
GlowEntity glowPassenger = (GlowEntity) passenger;
if (this instanceof Vehicle && glowPassenger instanceof LivingEntity) {
VehicleExitEvent event = EventFactory.getInstance().callEvent(new VehicleExitEvent((Vehicle) this, (LivingEntity) glowPassenger));
if (event.isCancelled()) {
return false;
}
}
passengerChanged = true;
glowPassenger.vehicle = null;
glowPassenger.teleport(getDismountLocation());
return passengers.remove(passenger);
}
Aggregations