*/
@EventHandler(
ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(final ProjectileLaunchEvent event) {
// The shooter needs to be a player.
final Projectile projectile = event.getEntity();
final Player player = BridgeMisc.getShooterPlayer(projectile);
if (player == null) {
return;
}
// And the projectile must be one the following:
EntityType type = event.getEntityType();
switch (type) {
case ENDER_PEARL:
break;
case ENDER_SIGNAL:
break;
case EGG:
break;
case SNOWBALL:
break;
case THROWN_EXP_BOTTLE:
break;
case SPLASH_POTION:
break;
default:
return;
}
// Do the actual check...
boolean cancel = false;
if (speed.isEnabled(player)){
final long now = System.currentTimeMillis();
final Location loc = player.getLocation(useLoc);
if (Combined.checkYawRate(player, loc.getYaw(), now, loc.getWorld().getName())){
// Yawrate (checked extra).
cancel = true;
}
if (speed.check(player)){
// If the check was positive, cancel the event.
cancel = true;
}
else if (Improbable.check(player, 0.6f, now, "blockplace.speed")){
// Combined fighting speed.
cancel = true;
}
}
// Ender pearl glitch (ab-) use.
if (!cancel && type == EntityType.ENDER_PEARL){
if (!CombinedConfig.getConfig(player).enderPearlCheck){
// Do nothing !
// TODO: Might have further flags?
}
else if (!BlockProperties.isPassable(projectile.getLocation(useLoc))){
// Launch into a block.
// TODO: This might be a general check later.
cancel = true;
}
else{
if (!BlockProperties.isPassable(player.getEyeLocation(), projectile.getLocation(useLoc))){
// (Spare a useLoc2, for this is seldom rather.)
// Something between player
// TODO: This might be a general check later.
cancel = true;
}
else{
final Material mat = player.getLocation(useLoc).getBlock().getType();
final long flags = BlockProperties.F_CLIMBABLE | BlockProperties.F_LIQUID | BlockProperties.F_IGN_PASSABLE;
if (mat != null && mat != Material.AIR && (BlockProperties.getBlockFlags(mat) & flags) == 0 && !mcAccess.hasGravity(mat)){
// Still fails on piston traps etc.
if (!BlockProperties.isPassable(player.getLocation(), projectile.getLocation()) && !BlockProperties.isOnGroundOrResetCond(player, player.getLocation(), MovingConfig.getConfig(player).yOnGround)){
cancel = true;
}
}
}
}