Prevent VehicleEnterEvent being sent when player exits vehicle.

Fix for BUKKIT-223.

Issue BUKKIT-223: When a player exits a minecart or boat, both a
VehicleExitEvent and a VehicleEnterEvent are fired.  Only the
VehicleExitEvent should fire.

Reason for bug: This occurs because the VehicleEnterEvent is fired in
EntityBoat.b and EntityMinecart.b *any* time a player right-clicks on
a vehicle, whether the right-click is to enter the vehicle or exit it.

Fix: By moving the creation of VehicleEnterEvents from EntityBoat.b
and EntityMinecart.b to Entity.setPassengerOf, we can create either a
VehicleEnterEvent or a VehicleExitEvent, depending on whether the
player is entering or exiting a vehicle.
This commit is contained in:
Sam Wilson
2011-12-16 12:31:00 -08:00
committed by Andrew Ardill
parent 2c72f9f5af
commit a7744ac751
3 changed files with 13 additions and 28 deletions

View File

@@ -725,14 +725,7 @@ public class EntityMinecart extends Entity implements IInventory {
}
if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.type == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
if (!collisionEvent.isPickupCancelled()) {
VehicleEnterEvent enterEvent = new VehicleEnterEvent(vehicle, hitEntity);
this.world.getServer().getPluginManager().callEvent(enterEvent);
if (!enterEvent.isCancelled()) {
entity.mount(this);
}
}
entity.mount(this);
}
// CraftBukkit end
@@ -857,17 +850,6 @@ public class EntityMinecart extends Entity implements IInventory {
}
if (!this.world.isStatic) {
// CraftBukkit start
org.bukkit.entity.Entity player = (entityhuman == null) ? null : entityhuman.getBukkitEntity();
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) this.getBukkitEntity(), player);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
// CraftBukkit end
entityhuman.mount(this);
}
} else if (this.type == 1) {