use of fr.neatmonster.nocheatplus.checks.moving.MovingConfig in project NoCheatPlus by NoCheatPlus.
the class NoFall method checkDamage.
/**
* This is called if a player fails a check and gets set back, to avoid using that to avoid fall damage the player might be dealt damage here.
* @param player
* @param data
*/
public void checkDamage(final Player player, final double y, final MovingData data, final IPlayerData pData) {
final MovingConfig cc = pData.getGenericInstance(MovingConfig.class);
// Deal damage.
handleOnGround(player, y, data.hasSetBack() ? data.getSetBackY() : Double.NEGATIVE_INFINITY, false, data, cc, pData);
}
use of fr.neatmonster.nocheatplus.checks.moving.MovingConfig in project NoCheatPlus by NoCheatPlus.
the class Critical method check.
/**
* Checks a player.
*
* @param player
* the player
* @return true, if successful
*/
public boolean check(final Player player, final Location loc, final FightData data, final FightConfig cc, final IPlayerData pData, final IPenaltyList penaltyList) {
boolean cancel = false;
final double mcFallDistance = (double) player.getFallDistance();
// not in liquid, not in vehicle, and without blindness effect).
if (mcFallDistance > 0.0 && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)) {
if (pData.isDebugActive(type)) {
debug(player, "y=" + loc.getY() + " mcfalldist=" + mcFallDistance);
}
// Might be a violation.
final MovingConfig mcc = pData.getGenericInstance(MovingConfig.class);
final MovingData dataM = pData.getGenericInstance(MovingData.class);
// TODO: Skip near the highest jump height (needs check if head collided with something solid, which also detects low jump).
if (!dataM.isVelocityJumpPhase() && (dataM.sfLowJump && !dataM.sfNoLowJump && dataM.liftOffEnvelope == LiftOffEnvelope.NORMAL || mcFallDistance < cc.criticalFallDistance && !BlockProperties.isResetCond(player, loc, mcc.yOnGround))) {
// TODO: Use past move tracking to check for SurvivalFly and the like?
final PlayerMoveInfo moveInfo = auxMoving.usePlayerMoveInfo();
moveInfo.set(player, loc, null, mcc.yOnGround);
if (MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, dataM, mcc, pData)) {
data.criticalVL += 1.0;
// Execute whatever actions are associated with this check and
// the violation level and find out if we should cancel the event.
final ViolationData vd = new ViolationData(this, player, data.criticalVL, 1.0, cc.criticalActions);
if (vd.needsParameters()) {
final List<String> tags = new ArrayList<String>();
if (dataM.sfLowJump) {
tags.add("lowjump");
}
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd).willCancel();
// TODO: Introduce penalty instead of cancel.
}
auxMoving.returnPlayerMoveInfo(moveInfo);
}
}
return cancel;
}
Aggregations