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.
Dieser Commit ist enthalten in:
Ursprung
5c861fe864
Commit
c62375f95e
@ -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);
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren