Search in sources :

Example 21 with Vehicle

use of org.bukkit.entity.Vehicle 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)21 EventHandler (org.bukkit.event.EventHandler)12 Player (org.bukkit.entity.Player)9 Location (org.bukkit.Location)6 Entity (org.bukkit.entity.Entity)6 Vector (org.bukkit.util.Vector)3 Minigame (au.com.mineauz.minigames.minigame.Minigame)2 Team (au.com.mineauz.minigames.minigame.Team)2 DynamicMinigameStat (au.com.mineauz.minigames.stats.DynamicMinigameStat)2 StoredGameStats (au.com.mineauz.minigames.stats.StoredGameStats)2 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)2 IntVector3 (com.bergerkiller.bukkit.common.bases.IntVector3)2 BlockData (com.bergerkiller.bukkit.common.wrappers.BlockData)2 MovingData (fr.neatmonster.nocheatplus.checks.moving.MovingData)2 IPlayerData (fr.neatmonster.nocheatplus.players.IPlayerData)2 RichBoundsLocation (fr.neatmonster.nocheatplus.utilities.location.RichBoundsLocation)2 Random (java.util.Random)2 Boat (org.bukkit.entity.Boat)2 LivingEntity (org.bukkit.entity.LivingEntity)2 VehicleExitEvent (org.bukkit.event.vehicle.VehicleExitEvent)2