}
@EventHandler(priority=EventPriority.HIGHEST)
public void vehicleDamageDealt(VehicleDamageEvent event)
{
AutoRefMatch match = plugin.getMatch(event.getVehicle().getWorld());
if (match == null || !match.getCurrentState().inProgress()) return;
if (match.getCurrentState().inProgress() && event.getAttacker() != null)
{
Player damager = entityToPlayer(event.getAttacker());
if (!match.getPlayer(damager).isInsideLane())
{ event.setCancelled(true); return; }
// spectators cannot cause damage to any vehicle
if (match.getCurrentState().inProgress() &&
null != damager && match.isSpectator(damager))
{ event.setCancelled(true); return; }
AutoRefPlayer apl = match.getPlayer(damager);
if (apl != null)
{
Location loc = event.getVehicle().getLocation();
if (!apl.isInsideLane() || apl.getTeam().hasFlag(loc, Flag.NO_ACCESS))
{ event.setCancelled(true); return; }