Search in sources :

Example 11 with MovingConfig

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);
}
Also used : MovingConfig(fr.neatmonster.nocheatplus.checks.moving.MovingConfig)

Example 12 with MovingConfig

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;
}
Also used : MovingData(fr.neatmonster.nocheatplus.checks.moving.MovingData) ArrayList(java.util.ArrayList) MovingConfig(fr.neatmonster.nocheatplus.checks.moving.MovingConfig) ViolationData(fr.neatmonster.nocheatplus.checks.ViolationData) PlayerMoveInfo(fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo)

Aggregations

MovingConfig (fr.neatmonster.nocheatplus.checks.moving.MovingConfig)12 Location (org.bukkit.Location)6 MovingData (fr.neatmonster.nocheatplus.checks.moving.MovingData)5 RichBoundsLocation (fr.neatmonster.nocheatplus.utilities.location.RichBoundsLocation)5 IPlayerData (fr.neatmonster.nocheatplus.players.IPlayerData)3 Player (org.bukkit.entity.Player)3 PlayerMoveData (fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData)2 PlayerMoveInfo (fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo)2 VehicleMoveData (fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData)2 ArrayList (java.util.ArrayList)2 Entity (org.bukkit.entity.Entity)2 EventHandler (org.bukkit.event.EventHandler)2 ViolationData (fr.neatmonster.nocheatplus.checks.ViolationData)1 SetBackEntry (fr.neatmonster.nocheatplus.checks.moving.location.setback.SetBackEntry)1 LocationTrace (fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace)1 VehicleMoveInfo (fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo)1 PlayerSetBackMethod (fr.neatmonster.nocheatplus.checks.moving.player.PlayerSetBackMethod)1 AuxMoving (fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving)1 AccountEntry (fr.neatmonster.nocheatplus.checks.moving.velocity.AccountEntry)1 SimpleEntry (fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry)1