mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-29 11:57:59 +01:00
Adapt to ActionFrequncy changes.
This commit is contained in:
parent
3bac9c9530
commit
b3b88a7513
@ -74,7 +74,7 @@ public class FastBreak extends Check {
|
||||
data.fastBreakPenalties.add(now, (float) missingTime);
|
||||
|
||||
// Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
|
||||
if (data.fastBreakPenalties.getScore(cc.fastBreakBucketFactor) > cc.fastBreakBucketContention){
|
||||
if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakBucketContention){
|
||||
// TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
|
||||
final double vlAdded = (double) missingTime / 1000.0;
|
||||
data.fastBreakVL += vlAdded;
|
||||
|
@ -24,7 +24,7 @@ public class Frequency extends Check {
|
||||
data.frequencyBuckets.add(System.currentTimeMillis(), interval);
|
||||
|
||||
// Full period frequency.
|
||||
final float fullScore = data.frequencyBuckets.getScore(cc.frequencyBucketFactor);
|
||||
final float fullScore = data.frequencyBuckets.score(cc.frequencyBucketFactor);
|
||||
final float fullTime = cc.frequencyBuckets * cc.frequencyBucketDur;
|
||||
|
||||
// Short term arrivals.
|
||||
|
@ -58,7 +58,7 @@ public class WrongBlock extends Check {
|
||||
player.sendMessage("WrongBlock failure with dist: " + dist);
|
||||
}
|
||||
data.wrongBlockVL.add(now, (float) (dist + 1) / 2f);
|
||||
final float score = data.wrongBlockVL.getScore(0.9f);
|
||||
final float score = data.wrongBlockVL.score(0.9f);
|
||||
if (score > cc.wrongBLockLevel){
|
||||
if (executeActions(player, score, 1D, cc.wrongBlockActions))
|
||||
cancel = true;
|
||||
|
@ -51,7 +51,7 @@ public class Commands extends Check {
|
||||
data.commandsShortTermWeight = 1.0;
|
||||
}
|
||||
|
||||
final float nw = data.commandsWeights.getScore(1f);
|
||||
final float nw = data.commandsWeights.score(1f);
|
||||
final double violation = Math.max(nw - cc.commandsLevel, data.commandsShortTermWeight - cc.commandsShortTermLevel);
|
||||
|
||||
if (violation > 0.0){
|
||||
|
@ -35,7 +35,7 @@ public class Logins extends Check {
|
||||
final long durBucket = 1000L * cc.loginsSeconds / 6;
|
||||
final ActionFrequency freq = getActionFrequency(player.getWorld().getName(), 6, durBucket, cc.loginsPerWorldCount);
|
||||
freq.update(now);
|
||||
final boolean cancel = freq.getScore(1f) > cc.loginsLimit;
|
||||
final boolean cancel = freq.score(1f) > cc.loginsLimit;
|
||||
if (!cancel) freq.add(now, 1f);
|
||||
return cancel;
|
||||
}
|
||||
|
@ -233,13 +233,13 @@ public class Text extends AsyncCheck implements INotifyReload{
|
||||
// Add weight to frequency counts.
|
||||
final float normalScore = Math.max(cc.textFreqNormMin, score);
|
||||
data.chatFrequency.add(time, normalScore);
|
||||
final float accumulated = cc.textFreqNormWeight * data.chatFrequency.getScore(cc.textFreqNormFactor);
|
||||
final float accumulated = cc.textFreqNormWeight * data.chatFrequency.score(cc.textFreqNormFactor);
|
||||
final boolean normalViolation = accumulated > cc.textFreqNormLevel;
|
||||
|
||||
final float shortTermScore = Math.max(cc.textFreqShortTermMin, score);
|
||||
data.chatShortTermFrequency.add(time, shortTermScore);
|
||||
// TODO: very short term (1st bucket) or do it indirectly.
|
||||
final float shortTermAccumulated = cc.textFreqShortTermWeight * data.chatShortTermFrequency.getScore(cc.textFreqShortTermFactor);
|
||||
final float shortTermAccumulated = cc.textFreqShortTermWeight * data.chatShortTermFrequency.score(cc.textFreqShortTermFactor);
|
||||
final boolean shortTermViolation = shortTermAccumulated > cc.textFreqShortTermLevel;
|
||||
|
||||
if (normalViolation || shortTermViolation){
|
||||
|
@ -79,7 +79,7 @@ public class FlatWords extends DigestedWords{
|
||||
return 0.0f;
|
||||
}
|
||||
freq.update(ts);
|
||||
float score = Math.min(1.0f, freq.getScore(factor));
|
||||
float score = Math.min(1.0f, freq.score(factor));
|
||||
freq.add(ts, 1.0f);
|
||||
return score;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class Combined {
|
||||
final CombinedConfig cc = CombinedConfig.getConfig(player);
|
||||
|
||||
// Angle diff per second
|
||||
final float total = Math.max(data.yawFreq.getScore(1f), data.yawFreq.getScore(0) * 3f);
|
||||
final float total = Math.max(data.yawFreq.score(1f), data.yawFreq.bucketScore(0) * 3f);
|
||||
final float threshold = cc.yawRate;
|
||||
boolean cancel = false;
|
||||
if (total > threshold){
|
||||
|
@ -41,14 +41,14 @@ public class Improbable extends Check {
|
||||
final CombinedData data = CombinedData.getData(player);
|
||||
final CombinedConfig cc = CombinedConfig.getConfig(player);
|
||||
data.improbableCount.add(now, weight);
|
||||
final float shortTerm = data.improbableCount.getScore(0);
|
||||
final float shortTerm = data.improbableCount.bucketScore(0);
|
||||
double violation = 0;
|
||||
boolean violated = false;
|
||||
if (shortTerm * 0.8f > cc.improbableLevel / 20.0){
|
||||
violation += shortTerm * 2d;
|
||||
violated = true;
|
||||
}
|
||||
final double full = data.improbableCount.getScore(1.0f);
|
||||
final double full = data.improbableCount.score(1.0f);
|
||||
if (full > cc.improbableLevel){
|
||||
violation += full;
|
||||
violated = true;
|
||||
|
@ -18,7 +18,7 @@ public class SelfHit extends Check {
|
||||
// Treat self hitting as instant violation.
|
||||
data.selfHitVL.add(System.currentTimeMillis(), 1.0f);
|
||||
// NOTE: This lets VL decrease slightly over 30 seconds, one could also use a number, but this is more tolerant.
|
||||
cancel = executeActions(damager, data.selfHitVL.getScore(0.99f), 1.0f, cc.selfHitActions);
|
||||
cancel = executeActions(damager, data.selfHitVL.score(0.99f), 1.0f, cc.selfHitActions);
|
||||
|
||||
return cancel;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class Speed extends Check {
|
||||
data.speedBuckets.add(now, 1f);
|
||||
|
||||
// Medium term (normalized to one second).
|
||||
final float total = data.speedBuckets.getScore(cc.speedBucketFactor) * 1000f / (float) (cc.speedBucketDur * cc.speedBuckets);
|
||||
final float total = data.speedBuckets.score(cc.speedBucketFactor) * 1000f / (float) (cc.speedBucketDur * cc.speedBuckets);
|
||||
|
||||
// Short term.
|
||||
final int tick = TickTask.getTick();
|
||||
|
@ -354,7 +354,7 @@ public class SurvivalFly extends Check {
|
||||
System.out.println(player.getName() + " vertical freedom: " + data.verticalFreedom + " ("+data.verticalVelocity+"/"+data.verticalVelocityCounter+"), jumpphase: " + data.survivalFlyJumpPhase);
|
||||
System.out.println(player.getName() + " hDist: " + hDistance + " / " + hAllowedDistance + " , vDist: " + (yDistance) + " ("+player.getVelocity().getY()+")" + " / " + vAllowedDistance);
|
||||
System.out.println(player.getName() + " y" + (fromOnGround?"(onground)":"") + (data.noFallAssumeGround?"(assumeonground)":"") + ": " + from.getY() +"(" + player.getLocation().getY() + ") -> " + to.getY()+ (toOnGround?"(onground)":""));
|
||||
if (cc.survivalFlyAccounting) System.out.println(player.getName() + " h=" + data.hDistSum.getScore(1f)+"/" + data.hDistSum.getScore(1) + " , v=" + data.vDistSum.getScore(1f)+"/"+data.vDistSum.getScore(1) );
|
||||
if (cc.survivalFlyAccounting) System.out.println(player.getName() + " h=" + data.hDistSum.score(1f)+"/" + data.hDistSum.bucketScore(1) + " , v=" + data.vDistSum.score(1f)+"/"+data.vDistSum.bucketScore(1) );
|
||||
System.out.println(player.getName() + " tags: " + CheckUtils.join(tags, "+"));
|
||||
}
|
||||
|
||||
@ -437,25 +437,27 @@ public class SurvivalFly extends Check {
|
||||
|
||||
/**
|
||||
* Keep track of values, demanding that with time the values decrease.<br>
|
||||
* The ActionFrequency objects have 3 buckets.
|
||||
* The ActionFrequency objects have 3 buckets, bucket 1 is checked against bucket 2, 0 is ignored.
|
||||
* @param now
|
||||
* @param value
|
||||
* @param sum
|
||||
* @param count
|
||||
* @param tags
|
||||
* @param tag
|
||||
* @return
|
||||
* @return absolute difference on violation.;
|
||||
*/
|
||||
private static final double doAccounting(final long now, final double value, final ActionFrequency sum, final ActionFrequency count, final ArrayList<String> tags, String tag)
|
||||
{
|
||||
sum.add(now, (float) value);
|
||||
count.add(now, 1f);
|
||||
if (count.getScore(2) > 0 && count.getScore(1) > 0) {
|
||||
final float sc0 = sum.getScore(1);
|
||||
final float sc1 = sum.getScore(2);
|
||||
if (sc0 < sc1 || value < 3.9 && sc0 == sc1) {
|
||||
// TODO: This does not make sense (vertical vs horizontal up vs down: needs parameter !).
|
||||
// TODO: Add hover return parameter
|
||||
if (count.bucketScore(2) > 0 && count.bucketScore(1) > 0) {
|
||||
final float sc1 = sum.bucketScore(1);
|
||||
final float sc2 = sum.bucketScore(2);
|
||||
if (sc1 < sc2 || value < 3.9 && sc1 == sc2) {
|
||||
tags.add(tag);
|
||||
return sc0 - sc1;
|
||||
return sc1 - sc2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user