Search in sources :

Example 1 with VehicleMoveInfo

use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo in project NoCheatPlus by NoCheatPlus.

the class AuxMoving method clear.

/**
 * Clear parked MovingInfo instances. Called on reload and data removal and
 * setMCAccess.
 */
public void clear() {
    // (Players)
    for (final PlayerMoveInfo info : parkedPlayerMoveInfo) {
        info.cleanup();
    }
    parkedPlayerMoveInfo.clear();
    // (Vehicles)
    for (final VehicleMoveInfo info : parkedVehicleMoveInfo) {
        info.cleanup();
    }
    parkedVehicleMoveInfo.clear();
}
Also used : PlayerMoveInfo(fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo) VehicleMoveInfo(fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo)

Example 2 with VehicleMoveInfo

use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo in project NoCheatPlus by NoCheatPlus.

the class AuxMoving method resetVehiclePositions.

/**
 * Convenience method for calling data.resetVehiclePositions (analogous to
 * resetPosisionsAndMediumProperties for players), wrapping vehicleLocation
 * with a RichEntityLocation(VehicleMoveInfo).
 *
 * @param vehicle
 * @param vehicleLocation
 * @param data
 * @param cc
 */
public void resetVehiclePositions(final Entity vehicle, final Location vehicleLocation, final MovingData data, final MovingConfig cc) {
    final VehicleMoveInfo vMoveInfo = useVehicleMoveInfo();
    vMoveInfo.set(vehicle, vehicleLocation, null, cc.yOnGround);
    data.resetVehiclePositions(vMoveInfo.from);
    returnVehicleMoveInfo(vMoveInfo);
}
Also used : VehicleMoveInfo(fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo)

Example 3 with VehicleMoveInfo

use of fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo in project NoCheatPlus by NoCheatPlus.

the class VehicleChecks method checkVehicleMove.

/**
 * Uses both useLoc1 and useLoc2, possibly others too.
 *
 * @param vehicle
 * @param vehicleType
 * @param from
 *            May be null, may be ignored anyway. Might be used as
 *            firstPastMove, in case of data missing.
 * @param to
 *            May be null, may be ignored anyway.
 * @param player
 * @param fake
 * @param data
 * @param pData2
 * @param debug
 */
private void checkVehicleMove(final Entity vehicle, final EntityType vehicleType, final Location from, final Location to, final Player player, final boolean fake, final MovingData data, final IPlayerData pData, boolean debug) {
    // TODO: Detect teleportation and similar.
    final MovingConfig cc = pData.getGenericInstance(MovingConfig.class);
    // Exclude certain vehicle types.
    if (cc.ignoredVehicles.contains(vehicleType)) {
        // 100% legit.
        data.clearVehicleData();
        return;
    }
    final World world = vehicle.getWorld();
    final VehicleMoveInfo moveInfo = aux.useVehicleMoveInfo();
    // vehicleLocation: Track when it could become null! -> checkIllegal  -> no setback or null location.
    final Location vehicleLocation = vehicle.getLocation(moveInfo.useLoc);
    final VehicleMoveData firstPastMove = data.vehicleMoves.getFirstPastMove();
    // Ensure firstPastMove is valid.
    if (!firstPastMove.valid) {
        // Determine the best location to use as past move.
        // TODO: Could also check the set backs for plausible entries, however that would lead to a violation by default. Could use an indicator.
        final Location refLoc = from == null ? vehicleLocation : from;
        MovingUtil.ensureChunksLoaded(player, refLoc, "vehicle move (no past move)", data, cc, pData);
        aux.resetVehiclePositions(vehicle, refLoc, data, cc);
        if (pData.isDebugActive(checkType)) {
            // TODO: Might warn instead.
            debug(player, "Missing past move data, set to: " + firstPastMove.from);
        }
    }
    // Determine best locations to use.
    // (Currently always use firstPastMove and vehicleLocation.)
    final Location useFrom = LocUtil.set(useLoc1, world, firstPastMove.toIsValid ? firstPastMove.to : firstPastMove.from);
    final Location useTo = vehicleLocation;
    // Initialize moveInfo.
    if (vehicleType == EntityType.PIG) {
        // TODO: Special cases by config rather.
        // TODO: Likely will fail with passable.
        moveInfo.setExtendFullWidth(0.52);
    }
    // TODO: Test yOnGround at 0.13 instead of xz-margin
    moveInfo.set(vehicle, useFrom, useTo, // TODO: Extra config.
    vehicleType == EntityType.PIG ? Math.max(0.13, cc.yOnGround) : cc.yOnGround);
    moveInfo.setExtendFullWidth(0.0);
    // Check coordinates, just in case.
    if (checkIllegal(moveInfo.from, moveInfo.to)) {
        // Likely superfluous.
        // TODO: Obviously applies under unknown conditions.
        SetBackEntry newTo = data.vehicleSetBacks.getValidSafeMediumEntry();
        if (newTo == null) {
            recoverVehicleSetBack(player, vehicle, vehicleLocation, moveInfo, data, cc);
        }
        NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning(Streams.STATUS, CheckUtils.getLogMessagePrefix(player, CheckType.MOVING_VEHICLE) + "Illegal coordinates on checkVehicleMove: from: " + from + " , to: " + to);
        setBack(player, vehicle, newTo, data, cc, pData);
        aux.returnVehicleMoveInfo(moveInfo);
        return;
    }
    // Ensure chunks are loaded.
    MovingUtil.ensureChunksLoaded(player, useFrom, useTo, firstPastMove, "vehicle move", cc, pData);
    // Initialize currentMove.
    final VehicleMoveData thisMove = data.vehicleMoves.getCurrentMove();
    thisMove.set(moveInfo.from, moveInfo.to);
    // Prepare all extra properties by default for now.
    MovingUtil.prepareFullCheck(moveInfo.from, moveInfo.to, thisMove, cc.yOnGround);
    thisMove.setExtraVehicleProperties(vehicle);
    // Call checkVehicleMove for actual checks.
    checkVehicleMove(vehicle, vehicleType, vehicleLocation, world, moveInfo, thisMove, firstPastMove, player, fake, data, cc, pData);
    // Cleanup.
    aux.returnVehicleMoveInfo(moveInfo);
}
Also used : VehicleMoveData(fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData) SetBackEntry(fr.neatmonster.nocheatplus.checks.moving.location.setback.SetBackEntry) MovingConfig(fr.neatmonster.nocheatplus.checks.moving.MovingConfig) World(org.bukkit.World) VehicleMoveInfo(fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo) Location(org.bukkit.Location) RichBoundsLocation(fr.neatmonster.nocheatplus.utilities.location.RichBoundsLocation)

Aggregations

VehicleMoveInfo (fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveInfo)3 MovingConfig (fr.neatmonster.nocheatplus.checks.moving.MovingConfig)1 SetBackEntry (fr.neatmonster.nocheatplus.checks.moving.location.setback.SetBackEntry)1 PlayerMoveInfo (fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveInfo)1 VehicleMoveData (fr.neatmonster.nocheatplus.checks.moving.model.VehicleMoveData)1 RichBoundsLocation (fr.neatmonster.nocheatplus.utilities.location.RichBoundsLocation)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1