Search in sources :

Example 1 with VehicleExitEvent

use of org.bukkit.event.vehicle.VehicleExitEvent in project BKCommonLib by bergerhealer.

the class CommonListener method onPlayerInteractEntity.

/*
     * This is a temporary workaround until the VehicleExitEvent works again
     */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
protected void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (event.getPlayer().getVehicle() == event.getRightClicked() && event.getRightClicked() instanceof Vehicle) {
        // Call a player exit event
        final Vehicle vehicle = (Vehicle) event.getRightClicked();
        event.setCancelled(CommonUtil.callEvent(new VehicleExitEvent(vehicle, event.getPlayer())).isCancelled());
    }
}
Also used : Vehicle(org.bukkit.entity.Vehicle) VehicleExitEvent(org.bukkit.event.vehicle.VehicleExitEvent) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Vehicle (org.bukkit.entity.Vehicle)1 EventHandler (org.bukkit.event.EventHandler)1 VehicleExitEvent (org.bukkit.event.vehicle.VehicleExitEvent)1