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;
}
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;
}
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;
}
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);
}
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();
}
}
Aggregations