summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Mortensen <nate.richard.mortensen@gmail.com>2013-09-07 16:01:45 -0600
committerfeildmaster <admin@feildmaster.com>2013-09-09 22:07:27 -0500
commitc62375f95e5dfd7941365fceb68368221e18c466 (patch)
tree1f115731a275635cb872f6d48a799b1e5948a6ec
parent5c861fe864ac46eeffc8580814638c0590316233 (diff)
downloadcraftbukkit-c62375f95e5dfd7941365fceb68368221e18c466.tar
craftbukkit-c62375f95e5dfd7941365fceb68368221e18c466.tar.gz
craftbukkit-c62375f95e5dfd7941365fceb68368221e18c466.tar.lz
craftbukkit-c62375f95e5dfd7941365fceb68368221e18c466.tar.xz
craftbukkit-c62375f95e5dfd7941365fceb68368221e18c466.zip
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.
-rw-r--r--src/main/java/net/minecraft/server/Entity.java2
1 files changed, 1 insertions, 1 deletions
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);