@EventHandler public void onCustomEvent(ToPlayerInRegionEvent event) { Location l = event.getLocation(); RegionManager rm = getPlugin().getRegionManager(); Region r = rm.getRegion(l); if (r == null) return; RegionType rt = rm.getRegionType(r.getType()); int jumpMult = effect.regionHasEffect(rt.getEffects(), "man_cannon"); // Check if the region is a teleporter if (jumpMult == 0) return; // Check to see if the Townships has enough reagents if (!effect.hasReagents(l)) { return; } // Run upkeep but don't need to know if upkeep occured effect.forceUpkeep(event); // Launch the player into the air Player player = event.getPlayer(); float pitch = player.getEyeLocation().getPitch(); int jumpForwards = 1; if (pitch > 45) { jumpForwards = 1; } if (pitch > 0) { pitch = -pitch; } float multiplier = ((90f + pitch) / 50f); Vector v = player .getVelocity() .setY(1) .add( player .getLocation() .getDirection() .setY(0) .normalize() .multiply(multiplier * jumpForwards)); NCPExemptionManager.exemptPermanently(player, CheckType.MOVING); player.setVelocity(v.multiply(jumpMult)); player.setFallDistance(-8f * jumpMult); NCPExemptionManager.unexempt(player, CheckType.MOVING); }
/** * Checks if this check is enabled for the specified player. * * @param player the player * @return true, if the check is enabled */ public boolean isEnabled(final Player player) { try { if (!type.isEnabled(player) || player.hasPermission(type.getPermission())) return false; } catch (final Exception e) { // TODO: this should be mostly obsolete. LogUtil.logSevere(e); } return !NCPExemptionManager.isExempted(player, type); }