Add configuration to morepackets for "eps", i.e. events per second.

This commit is contained in:
asofold 2014-07-21 14:39:17 +02:00
parent d5c1e289a9
commit 039c4b407f
4 changed files with 12 additions and 9 deletions

View File

@ -9,7 +9,6 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.net.NetStatic;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
/**
* The MorePackets check will try to identify players that send more than the usual
@ -17,13 +16,7 @@ import fr.neatmonster.nocheatplus.utilities.TrigUtil;
* checks (flying/running).
*/
public class MorePackets extends Check {
/** The maximum number of packets per second that we accept. */
private final static int maxPackets = 22;
/** Assumed number of packets per second under ideal conditions. */
private final static int idealPackets = 20;
/**
* Instantiates a new more packets check.
*/
@ -67,7 +60,7 @@ public class MorePackets extends Check {
}
// Check for a violation of the set limits.
final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, maxPackets, idealPackets);
final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal);
// Process violation result.
if (violation > 0.0) {

View File

@ -76,6 +76,10 @@ public class MovingConfig extends ACheckConfig {
public final ActionList creativeFlyActions;
public final boolean morePacketsCheck;
/** Assumed number of packets per second under ideal conditions. */
public final float morePacketsEPSIdeal;
/** The maximum number of packets per second that we accept. */
public final float morePacketsEPSMax;
public final ActionList morePacketsActions;
public final boolean morePacketsVehicleCheck;
@ -167,6 +171,8 @@ public class MovingConfig extends ACheckConfig {
creativeFlyActions = config.getOptimizedActionList(ConfPaths.MOVING_CREATIVEFLY_ACTIONS, Permissions.MOVING_CREATIVEFLY);
morePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL);
morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX));
morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
morePacketsVehicleCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK);

View File

@ -503,6 +503,8 @@ public abstract class ConfPaths {
private static final String MOVING_MOREPACKETS = MOVING + "morepackets.";
public static final String MOVING_MOREPACKETS_CHECK = MOVING_MOREPACKETS + "active";
public static final String MOVING_MOREPACKETS_EPSIDEAL = MOVING_MOREPACKETS + "epsideal";
public static final String MOVING_MOREPACKETS_EPSMAX = MOVING_MOREPACKETS + "epsmax";
public static final String MOVING_MOREPACKETS_ACTIONS = MOVING_MOREPACKETS + "actions";
private static final String MOVING_MOREPACKETSVEHICLE = MOVING + "morepacketsvehicle.";

View File

@ -355,6 +355,8 @@ public class DefaultConfig extends ConfigFile {
"log:flyshort:3:5:f cancel vl>100 log:flyshort:0:5:if cancel vl>400 log:flylong:0:5:cif cancel");
set(ConfPaths.MOVING_MOREPACKETS_CHECK, true);
set(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL, 20);
set(ConfPaths.MOVING_MOREPACKETS_EPSMAX, 22);
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, "cancel vl>10 log:morepackets:0:2:if cancel vl>100 log:morepackets:0:2:if cancel cmd:kickpackets");
set(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK, true);