Search in sources :

Example 21 with ViolationData

use of fr.neatmonster.nocheatplus.checks.ViolationData 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)

Example 22 with ViolationData

use of fr.neatmonster.nocheatplus.checks.ViolationData in project NoCheatPlus by NoCheatPlus.

the class Reach method check.

/**
 * Checks a player.
 *
 * @param player
 *            the player
 * @param cc
 * @param location
 *            the location
 * @return true, if successful
 */
public boolean check(final Player player, final double eyeHeight, final Block block, final BlockBreakData data, final BlockBreakConfig cc) {
    boolean cancel = false;
    final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE;
    // Distance is calculated from eye location to center of targeted block. If the player is further away from their
    // target than allowed, the difference will be assigned to "distance".
    final Location loc = player.getLocation(useLoc);
    loc.setY(loc.getY() + eyeHeight);
    final double distance = TrigUtil.distance(loc, block) - distanceLimit;
    useLoc.setWorld(null);
    if (distance > 0) {
        // They failed, increment violation level.
        data.reachVL += distance;
        // Remember how much further than allowed he tried to reach for logging, if necessary.
        data.reachDistance = distance;
        // 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.reachVL, distance, cc.reachActions);
        vd.setParameter(ParameterName.REACH_DISTANCE, String.valueOf(Math.round(data.reachDistance)));
        cancel = executeActions(vd).willCancel();
    } else {
        // Player passed the check, reward them.
        data.reachVL *= 0.9D;
    }
    return cancel;
}
Also used : ViolationData(fr.neatmonster.nocheatplus.checks.ViolationData) Location(org.bukkit.Location)

Example 23 with ViolationData

use of fr.neatmonster.nocheatplus.checks.ViolationData in project NoCheatPlus by NoCheatPlus.

the class Reach method check.

/**
 * Checks a player.
 *
 * @param player
 *            the player
 * @param loc
 * @param cc
 * @param data2
 * @param location
 *            the location
 * @return true, if successful
 */
public boolean check(final Player player, final double eyeHeight, final Block block, final BlockPlaceData data, final BlockPlaceConfig cc) {
    boolean cancel = false;
    final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE;
    // Distance is calculated from eye location to center of targeted block. If the player is further away from their
    // target than allowed, the difference will be assigned to "distance".
    final Location eyeLoc = player.getLocation(useLoc);
    eyeLoc.setY(eyeLoc.getY() + eyeHeight);
    final double distance = TrigUtil.distance(eyeLoc, block) - distanceLimit;
    if (distance > 0) {
        // They failed, increment violation level.
        data.reachVL += distance;
        // Remember how much further than allowed they tried to reach for logging, if necessary.
        data.reachDistance = distance;
        // 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.reachVL, distance, cc.reachActions);
        vd.setParameter(ParameterName.REACH_DISTANCE, String.valueOf(data.reachDistance));
        cancel = executeActions(vd).willCancel();
    } else {
        // Player passed the check, reward them.
        data.reachVL *= 0.9D;
    }
    // Cleanup.
    useLoc.setWorld(null);
    return cancel;
}
Also used : ViolationData(fr.neatmonster.nocheatplus.checks.ViolationData) Location(org.bukkit.Location)

Example 24 with ViolationData

use of fr.neatmonster.nocheatplus.checks.ViolationData in project NoCheatPlus by NoCheatPlus.

the class CommandAction method debug.

private void debug(final D violationData, String command) {
    final String prefix;
    if (violationData instanceof ViolationData) {
        ViolationData vd = (ViolationData) violationData;
        prefix = CheckUtils.getLogMessagePrefix(vd.player, vd.check.getType());
    } else {
        prefix = "";
    }
    StaticLog.logDebug(prefix + "Execute command action: " + command);
}
Also used : ViolationData(fr.neatmonster.nocheatplus.checks.ViolationData)

Example 25 with ViolationData

use of fr.neatmonster.nocheatplus.checks.ViolationData in project NoCheatPlus by NoCheatPlus.

the class TickTask method executeActions.

// Special static methods, usually not called from outside.
/**
 * Force executing actions.<br>
 * Note: Only call from the main thread!
 */
public static void executeActions() {
    final List<ViolationData> copyActions;
    synchronized (actionLock) {
        if (delayedActions.isEmpty()) {
            return;
        }
        copyActions = delayedActions;
        delayedActions = new LinkedList<ViolationData>();
    }
    for (final ViolationData vd : copyActions) {
        vd.executeActions();
    }
}
Also used : ViolationData(fr.neatmonster.nocheatplus.checks.ViolationData)

Aggregations

ViolationData (fr.neatmonster.nocheatplus.checks.ViolationData)25 Location (org.bukkit.Location)5 Material (org.bukkit.Material)4 PlayerLocation (fr.neatmonster.nocheatplus.utilities.location.PlayerLocation)3 PlayerMoveData (fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData)2 ActionList (fr.neatmonster.nocheatplus.actions.ActionList)1 Check (fr.neatmonster.nocheatplus.checks.Check)1 BlockInteractData (fr.neatmonster.nocheatplus.checks.blockinteract.BlockInteractData)1 MovingConfig (fr.neatmonster.nocheatplus.checks.moving.MovingConfig)1 MovingData (fr.neatmonster.nocheatplus.checks.moving.MovingData)1 SetBackEntry (fr.neatmonster.nocheatplus.checks.moving.location.setback.SetBackEntry)1 ModelFlying (fr.neatmonster.nocheatplus.checks.moving.model.ModelFlying)1 PlayerMoveInfo (fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo)1 IPlayerData (fr.neatmonster.nocheatplus.players.IPlayerData)1 BlockCache (fr.neatmonster.nocheatplus.utilities.map.BlockCache)1 WrapBlockCache (fr.neatmonster.nocheatplus.utilities.map.WrapBlockCache)1 ArrayList (java.util.ArrayList)1 GameMode (org.bukkit.GameMode)1 ItemStack (org.bukkit.inventory.ItemStack)1