org.bukkit.event.vehicle.VehicleExitEvent Java Examples

The following examples show how to use org.bukkit.event.vehicle.VehicleExitEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExprVehicle.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Entity[] get(final Event e, final Entity[] source) {
	return get(source, new Converter<Entity, Entity>() {
		@Override
		@Nullable
		public Entity convert(final Entity p) {
			if (getTime() >= 0 && e instanceof VehicleEnterEvent && p.equals(((VehicleEnterEvent) e).getEntered()) && !Delay.isDelayed(e)) {
				return ((VehicleEnterEvent) e).getVehicle();
			}
			if (getTime() >= 0 && e instanceof VehicleExitEvent && p.equals(((VehicleExitEvent) e).getExited()) && !Delay.isDelayed(e)) {
				return ((VehicleExitEvent) e).getVehicle();
			}
			if (hasMountEvents) {
				if (getTime() >= 0 && e instanceof EntityMountEvent && p.equals(((EntityMountEvent) e).getEntity()) && !Delay.isDelayed(e)) {
					return ((EntityMountEvent) e).getMount();
				}
				if (getTime() >= 0 && e instanceof EntityDismountEvent && p.equals(((EntityDismountEvent) e).getEntity()) && !Delay.isDelayed(e)) {
					return ((EntityDismountEvent) e).getDismounted();
				}
			}
			return p.getVehicle();
		}
	});
}
 
Example #2
Source File: PlayerEventListener.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void vehicleExit(VehicleExitEvent e) {
    if(e.getExited() instanceof Player) {
        HawkPlayer pp = hawk.getHawkPlayer((Player)e.getExited());
        pp.sendSimulatedAction(new Runnable() {
            @Override
            public void run() {
                pp.setInVehicle(false);
            }
        });
    }
}
 
Example #3
Source File: PetEntityListener.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDismount(VehicleExitEvent event) {
    Entity e = event.getVehicle();
    if (plugin.isPet(e)) {
        IEntityPet entityPet = plugin.getPetEntity(e);
        if (entityPet.getPet().isOwnerRiding() && !entityPet.getPet().isOwnerInMountingProcess()) {
            Lang.sendTo(entityPet.getPet().getOwner(), Lang.RIDE_PET_OFF.toString());
            entityPet.getPet().ownerRidePet(false);
        }
    }
}
 
Example #4
Source File: SafeBoat.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param e - event
 *            This event aims to put the player in a safe place when they
 *            exit the boat
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBoatExit(VehicleExitEvent e) {
    final Entity boat = e.getVehicle();
    if (!boat.getType().equals(EntityType.BOAT)) {
        // Not a boat
        return;
    }
    // LivingEntity entity = e.getExited();
    final Entity entityObj = e.getExited();
    if (!(entityObj instanceof Player)) {
        return;
    }
    final Player player = (Player) entityObj;
    final World playerWorld = player.getWorld();
    if (!playerWorld.getName().equalsIgnoreCase(Settings.worldName)) {
        // Not the right world
        return;
    }
    if (SafeBoat.ignoreList.contains(player.getUniqueId())) {
        return;
    }
    // Set the boat exit flag for this player
    // midTeleport.add(player.getUniqueId());
    if (exitedBoat.containsKey(player.getUniqueId())) {
        // Debounce
        e.setCancelled(true);
    } else {
        exitedBoat.put(player.getUniqueId(), boat);
    }
    return;
}
 
Example #5
Source File: PetEntityListener.java    From EchoPet with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDismount(VehicleExitEvent event) {
    Entity e = event.getVehicle();
    if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet) {
        IEntityPet entityPet = (IEntityPet) ReflectionUtil.getEntityHandle(e);
        if (entityPet.getPet().isOwnerRiding() && !entityPet.getPet().isOwnerInMountingProcess()) {
            Lang.sendTo(entityPet.getPet().getOwner(), Lang.RIDE_PET_OFF.toString());
            entityPet.getPet().ownerRidePet(false);
        }
    }
}
 
Example #6
Source File: FreezeMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleExit(final VehicleExitEvent event) {
  if (freeze.isFrozen(event.getExited())) {
    event.setCancelled(true);
  }
}
 
Example #7
Source File: FreezeListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleExit(final VehicleExitEvent event) {
    if(freeze.isFrozen(event.getExited())) {
        event.setCancelled(true);
    }
}
 
Example #8
Source File: ExprVehicle.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
	return super.setTime(time, getExpr(), VehicleEnterEvent.class, VehicleExitEvent.class);
}
 
Example #9
Source File: ExprPassenger.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
	return super.setTime(time, vehicle, VehicleEnterEvent.class, VehicleExitEvent.class);
}
 
Example #10
Source File: ObserverModule.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onVehicleExit(VehicleExitEvent event) {
    if (event.getExited() instanceof Player && testObserverOrDead((Player) event.getExited())) {
        event.setCancelled(true);
    }
}