From c62375f95e5dfd7941365fceb68368221e18c466 Mon Sep 17 00:00:00 2001 From: Nate Mortensen Date: Sat, 7 Sep 2013 16:01:45 -0600 Subject: Check that a vehicle is a Vehicle before casting. Fixes BUKKIT-4749 When an entity is being moved as the passenger of an entity from one entity to another, a VehicleExitEvent is fired, but it is assumed that the current entity is a Vehicle. However, entities can be passengers of more than just Vehicles, which causes a ClassCastException to be thrown. This commit fixes the issue by checking that the current entity's vehicle's bukkitEntity is an instance of Vehicle before casting it to Vehicle. --- src/main/java/net/minecraft/server/Entity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 50edbdb5..2b951285 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1421,7 +1421,7 @@ public abstract class Entity { if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4)) { // It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are. VehicleExitEvent exitEvent = null; - if (this.vehicle != null) { + if (this.vehicle != null && this.vehicle.getBukkitEntity() instanceof Vehicle) { exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity); pluginManager.callEvent(exitEvent); -- cgit v1.2.3