Correctly fire VehicleExitEvent. Fixes BUKKIT-3761
This change makes it so that EntityHuman#setPassengerOf(Entity) invokes its parent method when leaving vehicles so that VehicleExitEvent is fired for players leaving vehicles. This change also fixes BUKKIT-2110, making it so VehicleExitEvent correctly handles cancellation. The implementation of VehicleExitEvent completely ignored the cancellation state of the event, making it so that cancelling the event had no effect. Cancelling a VehicleExitEvent now causes the entity to remain inside of the vehicle, with no visual stutter.
This commit is contained in:
@@ -304,6 +304,10 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||
public void setPassengerOf(Entity entity) {
|
||||
// CraftBukkit end
|
||||
if (this.vehicle != null && entity == null) {
|
||||
// CraftBukkit start - use parent method instead to correctly fire VehicleExitEvent
|
||||
Entity originalVehicle = this.vehicle;
|
||||
// First statement moved down, second statement handled in parent method.
|
||||
/*
|
||||
if (!this.world.isStatic) {
|
||||
this.l(this.vehicle);
|
||||
}
|
||||
@@ -313,6 +317,12 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
|
||||
}
|
||||
|
||||
this.vehicle = null;
|
||||
*/
|
||||
super.setPassengerOf(entity);
|
||||
if (!this.world.isStatic && this.vehicle == null) {
|
||||
this.l(originalVehicle);
|
||||
}
|
||||
// CraftBukkit end
|
||||
} else {
|
||||
super.setPassengerOf(entity); // CraftBukkit - call new parent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user