mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
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.
This commit is contained in:
parent
5c861fe864
commit
c62375f95e
1 changed files with 1 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue