@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); }
/** * Undo exempting a player from all checks. Note that exemption by meta data is not removed here. * * @param player the player */ public static final void unexempt(final Player player) { unexempt(player, CheckType.ALL); }
/** * Undo exempting a player form a certain check, or check group, as given. Note that exemption by * meta data is not removed here. * * @param player the player * @param checkType the check type */ public static final void unexempt(final Player player, final CheckType checkType) { // TODO: Consider settings for removing meta data as well. unexempt(player.getUniqueId(), checkType); }
/** * Undo exempting an entity from all checks. Includes players, note that exemption by meta data is * not removed here. * * @param id The unique id. */ public static final void unexempt(final UUID id) { unexempt(id, CheckType.ALL); }