mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-06 18:50:54 +01:00
Switch fastplace to monitor 2 seconds + shortterm (10 ticks by default).
This commit is contained in:
parent
df29e64bd9
commit
bd65c1218f
@ -75,7 +75,9 @@ public class BlockPlaceConfig extends ACheckConfig {
|
|||||||
public final ActionList directionActions;
|
public final ActionList directionActions;
|
||||||
|
|
||||||
public final boolean fastPlaceCheck;
|
public final boolean fastPlaceCheck;
|
||||||
public final long fastPlaceInterval;
|
public final int fastPlaceLimit;
|
||||||
|
public final int fastPlaceShortTermTicks;
|
||||||
|
public final int fastPlaceShortTermLimit;
|
||||||
public final ActionList fastPlaceActions;
|
public final ActionList fastPlaceActions;
|
||||||
|
|
||||||
public final boolean noSwingCheck;
|
public final boolean noSwingCheck;
|
||||||
@ -100,7 +102,9 @@ public class BlockPlaceConfig extends ACheckConfig {
|
|||||||
directionActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, Permissions.BLOCKPLACE_DIRECTION);
|
directionActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, Permissions.BLOCKPLACE_DIRECTION);
|
||||||
|
|
||||||
fastPlaceCheck = data.getBoolean(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK);
|
fastPlaceCheck = data.getBoolean(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK);
|
||||||
fastPlaceInterval = data.getLong(ConfPaths.BLOCKPLACE_FASTPLACE_INTERVAL);
|
fastPlaceLimit = data.getInt(ConfPaths.BLOCKPLACE_FASTPLACE_LIMIT);
|
||||||
|
fastPlaceShortTermTicks = data.getInt(ConfPaths.BLOCKPLACE_FASTPLACE_SHORTTERM_TICKS);
|
||||||
|
fastPlaceShortTermLimit = data.getInt(ConfPaths.BLOCKPLACE_FASTPLACE_SHORTTERM_LIMIT);
|
||||||
fastPlaceActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_FASTPLACE_ACTIONS, Permissions.BLOCKPLACE_FASTPLACE);
|
fastPlaceActions = data.getOptimizedActionList(ConfPaths.BLOCKPLACE_FASTPLACE_ACTIONS, Permissions.BLOCKPLACE_FASTPLACE);
|
||||||
|
|
||||||
noSwingCheck = data.getBoolean(ConfPaths.BLOCKPLACE_NOSWING_CHECK);
|
noSwingCheck = data.getBoolean(ConfPaths.BLOCKPLACE_NOSWING_CHECK);
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import fr.neatmonster.nocheatplus.checks.access.ACheckData;
|
import fr.neatmonster.nocheatplus.checks.access.ACheckData;
|
||||||
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
|
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
|
||||||
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* M#"""""""'M dP dP MM"""""""`YM dP
|
* M#"""""""'M dP dP MM"""""""`YM dP
|
||||||
@ -81,8 +82,9 @@ public class BlockPlaceData extends ACheckData {
|
|||||||
public double speedVL;
|
public double speedVL;
|
||||||
|
|
||||||
// Data of the fast place check.
|
// Data of the fast place check.
|
||||||
public long fastPlaceLastTime;
|
public final ActionFrequency fastPlaceBuckets = new ActionFrequency(2, 1000);
|
||||||
public boolean fastPlaceLastRefused;
|
public int fastPlaceShortTermTick = 0;
|
||||||
|
public int fastPlaceShortTermCount = 0;
|
||||||
|
|
||||||
// Data of the no swing check.
|
// Data of the no swing check.
|
||||||
public boolean noSwingArmSwung = true;
|
public boolean noSwingArmSwung = true;
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MM""""""""`M dP MM"""""""`YM dP
|
* MM""""""""`M dP MM"""""""`YM dP
|
||||||
@ -41,33 +41,36 @@ public class FastPlace extends Check {
|
|||||||
final BlockPlaceConfig cc = BlockPlaceConfig.getConfig(player);
|
final BlockPlaceConfig cc = BlockPlaceConfig.getConfig(player);
|
||||||
final BlockPlaceData data = BlockPlaceData.getData(player);
|
final BlockPlaceData data = BlockPlaceData.getData(player);
|
||||||
|
|
||||||
boolean cancel = false;
|
data.fastPlaceBuckets.add(System.currentTimeMillis(), 1f);
|
||||||
|
|
||||||
// Has the player placed blocks too quickly?
|
// Full period frequency.
|
||||||
if (data.fastPlaceLastTime != 0 && System.currentTimeMillis() - data.fastPlaceLastTime < cc.fastPlaceInterval) {
|
final float fullScore = data.fastPlaceBuckets.score(1f);
|
||||||
if (!LagMeasureTask.skipCheck()) {
|
|
||||||
if (data.fastPlaceLastRefused) {
|
// Short term arrivals.
|
||||||
final double difference = cc.fastPlaceInterval - System.currentTimeMillis()
|
final int tick = TickTask.getTick();
|
||||||
+ data.fastPlaceLastTime;
|
if (tick - data.fastPlaceShortTermTick < cc.fastPlaceShortTermTicks){
|
||||||
|
// Within range, add.
|
||||||
// He failed, increase his violation level.
|
data.fastPlaceShortTermCount ++;
|
||||||
data.fastPlaceVL += difference;
|
|
||||||
|
|
||||||
// Execute whatever actions are associated with this check and the violation level and find out if
|
|
||||||
// we should cancel the event.
|
|
||||||
cancel = executeActions(player, data.fastPlaceVL, difference, cc.fastPlaceActions);
|
|
||||||
}
|
|
||||||
|
|
||||||
data.fastPlaceLastRefused = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Reward him by lowering his violation level.
|
|
||||||
data.fastPlaceVL *= 0.9D;
|
|
||||||
data.fastPlaceLastRefused = false;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
data.fastPlaceLastTime = System.currentTimeMillis();
|
data.fastPlaceShortTermTick = tick;
|
||||||
|
data.fastPlaceShortTermCount = 1;
|
||||||
return cancel;
|
}
|
||||||
|
|
||||||
|
// Find if one of both or both are violations:
|
||||||
|
final float fullViolation = fullScore - cc.fastPlaceLimit;
|
||||||
|
final float shortTermViolation = data.fastPlaceShortTermCount - cc.fastPlaceShortTermLimit;
|
||||||
|
final float violation = Math.max(fullViolation, shortTermViolation);
|
||||||
|
|
||||||
|
boolean cancel = false;
|
||||||
|
if (violation > 0){
|
||||||
|
final double change = violation / 1000;
|
||||||
|
data.fastPlaceVL += change;
|
||||||
|
cancel = executeActions(player, data.fastPlaceVL, change, cc.fastPlaceActions);
|
||||||
|
}
|
||||||
|
else if (data.fastPlaceVL > 0d && fullScore < cc.fastPlaceLimit * .75)
|
||||||
|
data.fastPlaceVL *= 0.95;
|
||||||
|
|
||||||
|
return cancel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,10 @@ public abstract class ConfPaths {
|
|||||||
|
|
||||||
private static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + "fastplace.";
|
private static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + "fastplace.";
|
||||||
public static final String BLOCKPLACE_FASTPLACE_CHECK = BLOCKPLACE_FASTPLACE + "active";
|
public static final String BLOCKPLACE_FASTPLACE_CHECK = BLOCKPLACE_FASTPLACE + "active";
|
||||||
public static final String BLOCKPLACE_FASTPLACE_INTERVAL = BLOCKPLACE_FASTPLACE + "interval";
|
public static final String BLOCKPLACE_FASTPLACE_LIMIT = BLOCKPLACE_FASTPLACE + "limit";
|
||||||
|
private static final String BLOCKPLACE_FASTPLACE_SHORTTERM = BLOCKPLACE_FASTPLACE + "shortterm.";
|
||||||
|
public static final String BLOCKPLACE_FASTPLACE_SHORTTERM_TICKS = BLOCKPLACE_FASTPLACE_SHORTTERM + "ticks";
|
||||||
|
public static final String BLOCKPLACE_FASTPLACE_SHORTTERM_LIMIT = BLOCKPLACE_FASTPLACE_SHORTTERM + "limit";
|
||||||
public static final String BLOCKPLACE_FASTPLACE_ACTIONS = BLOCKPLACE_FASTPLACE + "actions";
|
public static final String BLOCKPLACE_FASTPLACE_ACTIONS = BLOCKPLACE_FASTPLACE + "actions";
|
||||||
|
|
||||||
private static final String BLOCKPLACE_NOSWING = BLOCKPLACE + "noswing.";
|
private static final String BLOCKPLACE_NOSWING = BLOCKPLACE + "noswing.";
|
||||||
|
@ -22,7 +22,7 @@ import org.bukkit.Material;
|
|||||||
public class DefaultConfig extends ConfigFile {
|
public class DefaultConfig extends ConfigFile {
|
||||||
|
|
||||||
/** NCP build needed for this config. */
|
/** NCP build needed for this config. */
|
||||||
public static final int buildNumber = 236;
|
public static final int buildNumber = 256;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new default configuration.
|
* Instantiates a new default configuration.
|
||||||
@ -128,7 +128,9 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, "cancel vl>10 log:bdirection:0:3:if cancel");
|
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, "cancel vl>10 log:bdirection:0:3:if cancel");
|
||||||
|
|
||||||
set(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK, true);
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_CHECK, true);
|
||||||
set(ConfPaths.BLOCKPLACE_FASTPLACE_INTERVAL, 95L);
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_LIMIT, 22);
|
||||||
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_SHORTTERM_TICKS, 10);
|
||||||
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_SHORTTERM_LIMIT, 6);
|
||||||
set(ConfPaths.BLOCKPLACE_FASTPLACE_ACTIONS, "cancel vl>100 log:fastplace:3:5:cif cancel");
|
set(ConfPaths.BLOCKPLACE_FASTPLACE_ACTIONS, "cancel vl>100 log:fastplace:3:5:cif cancel");
|
||||||
|
|
||||||
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
|
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user