mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-15 08:28:10 +02:00
[BLEEDING] Simplify and (hopefully) repair the criticals check.
* Remove on-ground check. * Always increase VL by 1, because clients could control it anyway. * Skip if the player is in a vehicle. * Remove adapting to lag.
This commit is contained in:
parent
3dea6580e4
commit
5f0c70f138
@ -17,7 +17,6 @@ import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
|||||||
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
import fr.neatmonster.nocheatplus.permissions.Permissions;
|
||||||
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
|
||||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A check used to verify that critical hits done by players are legit.
|
* A check used to verify that critical hits done by players are legit.
|
||||||
@ -41,51 +40,35 @@ public class Critical extends Check {
|
|||||||
public boolean check(final Player player, final Location loc, final FightData data, final FightConfig cc) {
|
public boolean check(final Player player, final Location loc, final FightData data, final FightConfig cc) {
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
|
|
||||||
final float mcFallDistance = player.getFallDistance();
|
final double mcFallDistance = (double) player.getFallDistance();
|
||||||
final MovingConfig mCc = MovingConfig.getConfig(player);
|
final MovingConfig mCc = MovingConfig.getConfig(player);
|
||||||
if (mcFallDistance > 0.0 && cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
|
// TODO: All debugging to the trace (later allow hooking your own trace).
|
||||||
|
if (mcFallDistance > 0.0 && cc.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
|
||||||
final MovingData mData = MovingData.getData(player);
|
final MovingData mData = MovingData.getData(player);
|
||||||
|
|
||||||
if (MovingListener.shouldCheckSurvivalFly(player, mData, mCc) && CheckType.MOVING_NOFALL.isEnabled(player)){
|
if (MovingListener.shouldCheckSurvivalFly(player, mData, mCc) && CheckType.MOVING_NOFALL.isEnabled(player)) {
|
||||||
// TODO: Set max y in MovingListener, to be independent of sf/nofall!
|
// TODO: Set max y in MovingListener, to be independent of sf/nofall!
|
||||||
player.sendMessage("Critical: fd=" + mcFallDistance + "(" + mData.noFallFallDistance +") y=" + loc.getY() + ((mData.hasSetBack() && mData.getSetBackY() < mData.noFallMaxY) ? (" jumped=" + StringUtil.fdec3.format(mData.noFallMaxY - mData.getSetBackY())): ""));
|
player.sendMessage("Critical: fd=" + mcFallDistance + "(" + mData.noFallFallDistance +") y=" + loc.getY() + ((mData.hasSetBack() && mData.getSetBackY() < mData.noFallMaxY) ? (" jumped=" + StringUtil.fdec3.format(mData.noFallMaxY - mData.getSetBackY())): ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the hit was a critical hit (positive fall distance, entity in the air, not on ladder, not in liquid
|
// Check if the hit was a critical hit (very small fall-distance, not on ladder,
|
||||||
// and without blindness effect).
|
// not in liquid, not in vehicle, and without blindness effect).
|
||||||
|
if (mcFallDistance > 0.0 && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)) {
|
||||||
// TODO: Skip the on-ground check somehow?
|
|
||||||
// TODO: Implement low jump penalty.
|
|
||||||
if (mcFallDistance > 0f && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){
|
|
||||||
// Might be a violation.
|
// Might be a violation.
|
||||||
final MovingData dataM = MovingData.getData(player);
|
final MovingData dataM = MovingData.getData(player);
|
||||||
if (dataM.sfLowJump || player.getFallDistance() < cc.criticalFallDistance && !BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround)){
|
|
||||||
|
// TODO: Skip near the highest jump height (needs check if head collided with something solid, which also detects low jump).
|
||||||
|
if (dataM.sfLowJump || mcFallDistance < cc.criticalFallDistance && !BlockProperties.isResetCond(player, loc, mCc.yOnGround)) {
|
||||||
final MovingConfig ccM = MovingConfig.getConfig(player);
|
final MovingConfig ccM = MovingConfig.getConfig(player);
|
||||||
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
|
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)) {
|
||||||
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance()) / cc.criticalFallDistance;
|
data.criticalVL += 1.0;
|
||||||
// TODO: Cleanup: velocity is more like the gravity constant.
|
// Execute whatever actions are associated with this check and
|
||||||
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY())) / cc.criticalVelocity;
|
// the violation level and find out if we should cancel the event.
|
||||||
double delta = deltaFallDistance > 0D ? deltaFallDistance : 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
|
final ViolationData vd = new ViolationData(this, player, data.criticalVL, 1.0, cc.criticalActions);
|
||||||
|
if (vd.needsParameters()) {
|
||||||
final List<String> tags = new ArrayList<String>();
|
final List<String> tags = new ArrayList<String>();
|
||||||
|
if (dataM.sfLowJump) {
|
||||||
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
|
|
||||||
if (TickTask.getLag(1000, true) < 1.5){
|
|
||||||
// TODO: 1.5 is a fantasy value.
|
|
||||||
// Increment the violation level.
|
|
||||||
data.criticalVL += delta;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
tags.add("lag");
|
|
||||||
delta = 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, delta, cc.criticalActions);
|
|
||||||
if (vd.needsParameters()){
|
|
||||||
if (dataM.sfLowJump){
|
|
||||||
tags.add("sf_lowjump");
|
tags.add("sf_lowjump");
|
||||||
}
|
}
|
||||||
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
|
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
|
||||||
|
@ -61,7 +61,6 @@ public class FightConfig extends ACheckConfig {
|
|||||||
|
|
||||||
public final boolean criticalCheck;
|
public final boolean criticalCheck;
|
||||||
public final double criticalFallDistance;
|
public final double criticalFallDistance;
|
||||||
public final double criticalVelocity;
|
|
||||||
public final ActionList criticalActions;
|
public final ActionList criticalActions;
|
||||||
|
|
||||||
public final boolean directionCheck;
|
public final boolean directionCheck;
|
||||||
@ -129,7 +128,6 @@ public class FightConfig extends ACheckConfig {
|
|||||||
|
|
||||||
criticalCheck = data.getBoolean(ConfPaths.FIGHT_CRITICAL_CHECK);
|
criticalCheck = data.getBoolean(ConfPaths.FIGHT_CRITICAL_CHECK);
|
||||||
criticalFallDistance = data.getDouble(ConfPaths.FIGHT_CRITICAL_FALLDISTANCE);
|
criticalFallDistance = data.getDouble(ConfPaths.FIGHT_CRITICAL_FALLDISTANCE);
|
||||||
criticalVelocity = data.getDouble(ConfPaths.FIGHT_CRITICAL_VELOCITY);
|
|
||||||
criticalActions = data.getOptimizedActionList(ConfPaths.FIGHT_CRITICAL_ACTIONS, Permissions.FIGHT_CRITICAL);
|
criticalActions = data.getOptimizedActionList(ConfPaths.FIGHT_CRITICAL_ACTIONS, Permissions.FIGHT_CRITICAL);
|
||||||
|
|
||||||
directionCheck = data.getBoolean(ConfPaths.FIGHT_DIRECTION_CHECK);
|
directionCheck = data.getBoolean(ConfPaths.FIGHT_DIRECTION_CHECK);
|
||||||
|
@ -387,7 +387,6 @@ public abstract class ConfPaths {
|
|||||||
private static final String FIGHT_CRITICAL = FIGHT + "critical.";
|
private static final String FIGHT_CRITICAL = FIGHT + "critical.";
|
||||||
public static final String FIGHT_CRITICAL_CHECK = FIGHT_CRITICAL + "active";
|
public static final String FIGHT_CRITICAL_CHECK = FIGHT_CRITICAL + "active";
|
||||||
public static final String FIGHT_CRITICAL_FALLDISTANCE = FIGHT_CRITICAL + "falldistance";
|
public static final String FIGHT_CRITICAL_FALLDISTANCE = FIGHT_CRITICAL + "falldistance";
|
||||||
public static final String FIGHT_CRITICAL_VELOCITY = FIGHT_CRITICAL + "velocity";
|
|
||||||
public static final String FIGHT_CRITICAL_ACTIONS = FIGHT_CRITICAL + "actions";
|
public static final String FIGHT_CRITICAL_ACTIONS = FIGHT_CRITICAL + "actions";
|
||||||
|
|
||||||
private static final String FIGHT_DIRECTION = FIGHT + "direction.";
|
private static final String FIGHT_DIRECTION = FIGHT + "direction.";
|
||||||
@ -642,6 +641,8 @@ public abstract class ConfPaths {
|
|||||||
public static final String BLOCKBREAK_FASTBREAK_MOD_CREATIVE = "checks.blockbreak.fastbreak.intervalcreative";
|
public static final String BLOCKBREAK_FASTBREAK_MOD_CREATIVE = "checks.blockbreak.fastbreak.intervalcreative";
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final String MOVING_PASSABLE_RAYTRACING_VCLIPONLY = "checks.moving.passable.raytracing.vcliponly";
|
public static final String MOVING_PASSABLE_RAYTRACING_VCLIPONLY = "checks.moving.passable.raytracing.vcliponly";
|
||||||
|
@Deprecated
|
||||||
|
public static final String FIGHT_CRITICAL_VELOCITY = "checks.fight.critical.velocity";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,6 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
|
|
||||||
set(ConfPaths.FIGHT_CRITICAL_CHECK, true);
|
set(ConfPaths.FIGHT_CRITICAL_CHECK, true);
|
||||||
set(ConfPaths.FIGHT_CRITICAL_FALLDISTANCE, 0.06251D);
|
set(ConfPaths.FIGHT_CRITICAL_FALLDISTANCE, 0.06251D);
|
||||||
set(ConfPaths.FIGHT_CRITICAL_VELOCITY, 0.1D);
|
|
||||||
set(ConfPaths.FIGHT_CRITICAL_ACTIONS, "cancel vl>50 log:critical:0:5:cif cancel");
|
set(ConfPaths.FIGHT_CRITICAL_ACTIONS, "cancel vl>50 log:critical:0:5:cif cancel");
|
||||||
|
|
||||||
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
|
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
|
||||||
|
@ -1326,6 +1326,23 @@ public class BlockProperties {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple checking method, heavy. No isIllegal check.
|
||||||
|
* @param player
|
||||||
|
* @param location
|
||||||
|
* @param yOnGround
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isResetCond(final Player player, final Location location, final double yOnGround) {
|
||||||
|
blockCache.setAccess(location.getWorld());
|
||||||
|
pLoc.setBlockCache(blockCache);
|
||||||
|
pLoc.set(location, player, yOnGround);
|
||||||
|
final boolean res = pLoc.isResetCond();
|
||||||
|
blockCache.cleanup();
|
||||||
|
pLoc.cleanup();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Straw-man-method to hide warnings. Rather intended for display in debug/alert messages.
|
* Straw-man-method to hide warnings. Rather intended for display in debug/alert messages.
|
||||||
* @param blockType
|
* @param blockType
|
||||||
|
Loading…
Reference in New Issue
Block a user